Codeforces Global Round 17


A. Anti Light's Cell Guessing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3
3 1
Output
2
1
----------------------------------------------------------------------------------------------------
B. Kalindrome Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
1
2
1 2
3
1 2 3
5
1 4 4 1 4
Output
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Keshi Is Throwing a Party
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 2
2 1
1 1
2
0 0
0 1
2
1 0
0 1
Output
2
1
2
----------------------------------------------------------------------------------------------------
D. Not Quite Lee
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2 4 7
Output
10
Input
10
12391240 103904 1000000000 4142834 12039 142035823 1032840 49932183 230194823 984293123
Output
996
----------------------------------------------------------------------------------------------------
E. AmShZ and G.O.A.T.
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 2 3
5
1 4 4 5 6
6
7 8 197860736 212611869 360417095 837913434
8
6 10 56026534 405137099 550504063 784959015 802926648 967281024
Output
0
1
2
3
----------------------------------------------------------------------------------------------------
F. Mashtali: a Space Oddysey
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 7
1 2 1
1 3 2
2 3 2
1 4 1
4 5 1
2 5 2
2 6 2
Output
2
1212212
Input
6 7
1 2 2
1 3 2
2 3 2
1 4 2
4 5 2
2 5 2
2 6 2
Output
0
1212212
Input
6 7
1 2 1
1 3 1
2 3 1
1 4 1
4 5 1
2 5 1
2 6 1
Output
2
1212212
----------------------------------------------------------------------------------------------------
G. AmShZ Wins a Bet
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
)(()(())))
Output
)((())))
----------------------------------------------------------------------------------------------------
H. Squid Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1 1 1 4 4
1 5
3 4
2 6
Output
2
Input
5 3
1 1 3 3
1 2
1 4
1 5
Output
-1
----------------------------------------------------------------------------------------------------
I. Mashtali vs AtCoder
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
2 3
2 4
4 5
Output
11122
Input
5
1 2
2 3
1 4
4 5
Output
21122
Input
6
1 2
2 4
5 1
6 3
3 2
Output
111111
Input
7
1 2
3 7
4 6
2 3
2 4
1 5
Output
2212222
----------------------------------------------------------------------------------------------------
