Codeforces Round 646 (Div. 2)


A. Odd Selection
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1
999
1 1
1000
2 1
51 50
2 2
51 50
3 3
101 102 103
Output
Yes
No
Yes
Yes
No
----------------------------------------------------------------------------------------------------
B. Subsequence Hate
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
001
100
101
010
0
1
001100
Output
0
0
1
1
0
0
2
----------------------------------------------------------------------------------------------------
C. Game On Leaves
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
3 1
2 1
3 1
Output
Ashish
Input
1
3 2
1 2
1 3
Output
Ayush
----------------------------------------------------------------------------------------------------
D. Guess The Maximums
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
4 2
2 1 3
2 2 4
1
2
3
4
Correct
Output
? 1 1
? 1 2
? 1 3
? 1 4
! 4 3
----------------------------------------------------------------------------------------------------
E. Tree Shuffling
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 0 1
20 1 0
300 0 1
4000 0 0
50000 1 0
1 2
2 3
2 4
1 5
Output
4
Input
5
10000 0 1
2000 1 0
300 0 1
40 0 0
1 1 0
1 2
2 3
2 4
1 5
Output
24000
Input
2
109 0 1
205 0 1
1 2
Output
-1
----------------------------------------------------------------------------------------------------
F. Rotating Substrings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1
a
a
2
ab
ba
3
abc
cab
3
abc
cba
4
abab
baba
4
abcc
aabc
Output
0
1
1
2
1
-1
----------------------------------------------------------------------------------------------------
