Codeforces Round 562 (Div. 2)


A. Circle Metro
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 4 3 2
Output
YES
Input
10 2 1 9 10
Output
NO
----------------------------------------------------------------------------------------------------
B. Pairs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 6
1 2
1 3
1 4
2 3
2 4
3 4
Output
NO
Input
5 4
1 2
2 3
3 4
4 5
Output
YES
Input
300000 5
1 2
1 2
1 2
1 2
1 2
Output
YES
----------------------------------------------------------------------------------------------------
C. Increasing by Modulo
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
0 0 0 1 2
Output
0
Input
5 7
0 6 1 3 2
Output
1
----------------------------------------------------------------------------------------------------
D. Good Triple
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
010101
Output
3
Input
11001100
Output
0
----------------------------------------------------------------------------------------------------
E. And Reachability
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
1 3 0 2 1
1 3
2 4
1 4
Output
Fou
Shi
Shi
----------------------------------------------------------------------------------------------------
