Codeforces Global Round 22


A. Glory Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
0 1 1 1
1 10 100 1000
6
0 0 0 1 1 1
3 4 5 6 7 8
3
1 1 1
1000000000 1000000000 1000000000
1
1
1
Output
2112
63
3000000000
1
----------------------------------------------------------------------------------------------------
B. Prefix Sum Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
5 5
1 2 3 4 5
7 4
-6 -5 -3 0
3 3
2 3 4
3 2
3 4
Output
Yes
Yes
No
No
----------------------------------------------------------------------------------------------------
C. Even Number Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 3 5
4
1 3 5 7
4
1 2 3 4
4
10 20 30 40
Output
Alice
Alice
Bob
Alice
----------------------------------------------------------------------------------------------------
D. Permutation Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
4
5 3 1 2
6
7 7 7 3 3 3
6
4 4 4 0 0 0
Output
2
1 3 2 4
3
1 2 3 4 5 6
3
6 5 4 3 2 1
----------------------------------------------------------------------------------------------------
E. Balance Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
1
1000000000
2
1 1
4
0 0 1 0
5
1 2 3 2 1
5
1 3 5 7 9
32
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Output
1
2
3
4
2
150994942
----------------------------------------------------------------------------------------------------
F. Connectivity Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1
5
2 2 2 2 0
2
4
2
4
Output
? 1
? 1
? 3
? 3
! 1 1 2 2 3
----------------------------------------------------------------------------------------------------
G. Anti-Increasing Addicts
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2
10
01
4 3
1110
0101
1010
0111
5 5
01111
10111
11011
11101
11110
5 2
10000
01111
01111
01111
01111
Output
YES
01
11
YES
0011
1111
1111
1100
NO
YES
01111
11000
10000
10000
10000
----------------------------------------------------------------------------------------------------
H. Palindrome Addicts
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
12
push a
pop
push a
push a
push b
push b
push a
push a
pop
pop
pop
push b
Output
1
0
1
2
3
4
5
6
5
4
3
4
----------------------------------------------------------------------------------------------------
