Codeforces Global Round 25


A. Dual Trigger
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10
1101010110
10
1001001110
6
000000
1
1
12
111111111111
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Battle Cows
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6 1
12 10 14 11 8 3
6 5
7 2 727 10 12 13
2 2
1000000000 1
Output
1
2
0
----------------------------------------------------------------------------------------------------
C. Ticket Hoarding
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 2 3
8 6 4 2
4 2 8
8 6 4 2
5 100 1
10000 1 100 10 1000
6 3 9
5 5 5 5 5 5
Output
10
64
1
72
----------------------------------------------------------------------------------------------------
D. Buying Jewels
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 3
6 4
255 8
Output
YES
10
2 3 4 5 6 7 8 9 10 11
NO
YES
8
128 64 32 16 8 4 2 1
----------------------------------------------------------------------------------------------------
E. No Palindromes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
sinktheyacht
lllllllll
uwuowouwu
Output
YES
1
sinktheyacht
NO
YES
3
uw uow ouwu
----------------------------------------------------------------------------------------------------
F. Inversion Composition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 4
2 3 1
5 5
2 3 5 1 4
6 11
5 1 2 3 4 6
9 51
3 1 4 2 5 6 7 8 9
1 0
1
Output
YES
3 2 1
NO
NO
YES
1 5 9 8 7 6 4 3 2
YES
1
----------------------------------------------------------------------------------------------------
G. Clacking Balls
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 10
5 1 4
2 15
15 1
6 6
1 2 3 4 5 6
6 9
6 5 4 3 2 1
1 100
69
Output
600000042
14
35
333333409
0
----------------------------------------------------------------------------------------------------
H. Thanos Snap
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1
1 2
2
4 3 2 1
3
5 1 6 4 7 2 8 3
4
10 15 6 12 1 3 4 9 13 5 7 16 14 11 2 8
5
32 2 5 23 19 17 31 7 29 3 4 16 13 9 30 24 14 1 8 20 6 15 26 18 10 27 22 12 25 21 28 11
Output
1
3 1
7 5 1
15 13 9 1
31 28 25 17 1
----------------------------------------------------------------------------------------------------
I. Growing Trees
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
5 5 1
4 3 5 5
2 1 5 7
2 4 6 2
5 3 3 5
2 5 2 9
5 5 3
4 3 5 5
2 1 5 7
2 4 6 2
5 3 3 5
2 5 2 9
2 1 10000000
1 2 1000 1000
10 15 10
7 1 7 6
5 8 6 6
4 8 2 2
4 3 10 9
10 8 3 4
4 6 6 1
5 4 1 3
9 3 4 3
8 3 9 9
7 5 10 3
2 1 3 4
6 1 6 4
2 5 7 3
10 7 2 1
8 2 6 8
Output
38
191
100000010000000000
2722
----------------------------------------------------------------------------------------------------
