Educational Codeforces Round 155 (Rated for Div. 2)


A. Rigged!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
7 4
9 3
4 6
2 2
2
4 6
100 100
2
1337 3
1337 3
Output
5
-1
-1
----------------------------------------------------------------------------------------------------
B. Chips on the Board
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 4 1
3 2 2
1
4
5
2
4 5
2 3
5
5 2 4 5 3
3 4 2 1 5
Output
10
9
13
24
----------------------------------------------------------------------------------------------------
C. Make it Alternating
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10010
111
0101
Output
1 2
2 6
0 1
----------------------------------------------------------------------------------------------------
D. Sum of XOR Functions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3 2
Output
12
Input
4
39 68 31 80
Output
1337
Input
7
313539461 779847196 221612534 488613315 633203958 394620685 761188160
Output
257421502
----------------------------------------------------------------------------------------------------
E. Interactive Game with Coloring
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 1 1
0
1
1
Output
1
1 1 1 1
1
Input
4
1 2 3
0
0 1 0
0
1 1 0
0
1 0 1
1
Output
3
3 1 2
2
1
3
Input
3
1 2
0
1 1
1
Output
2
1 2
1
----------------------------------------------------------------------------------------------------
F. Last Man Standing
time limit per test: 7 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3
3 1 2
3 11 5
1
100
200
4
5 9 5 1
9 2 9 10
Output
1 1 1 
20000 
0 4 0 0 
----------------------------------------------------------------------------------------------------
