Educational Codeforces Round 157 (Rated for Div. 2)


A. Treasure Chest
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5 7 2
10 5 0
5 8 2
Output
7
10
9
----------------------------------------------------------------------------------------------------
B. Points and Minimum Distance
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2
15 1 10 5
3
10 30 20 20 30 10
Output
9
10 1
15 5
20
20 20
10 30
10 30
----------------------------------------------------------------------------------------------------
C. Torn Lucky Ticket
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
5 93746 59 3746 593 746 5937 46 59374 6
Output
20
Input
5
2 22 222 2222 22222
Output
13
Input
3
1 1 1
Output
9
----------------------------------------------------------------------------------------------------
D. XOR Construction
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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

Examples
Input
3
3
8 7 4
7 1 10
2
8 4
5 10
9
8 8 5 5 5 4 4 1 4
2 7 5 2 8 9 7 1 9
10
9 8 7 6 5 5 4 3 2 1
7 1 6 7 5 8 8 4 9 6
1
10
5
1
10
5
Output
1 1 1
2 4 3
0 1 0
----------------------------------------------------------------------------------------------------
F. Fancy Arrays
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 0 1
1 4 25
4 7 2
1000000000 40 1000000000
Output
9
25
582
514035484
----------------------------------------------------------------------------------------------------
G. Two Characters, Two Colors
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
7
0100010
6 6 6 7 7 6 6
3 3 5 4 7 6 7
5
10111
9 8 5 7 5
4 4 7 8 4
10
0100000000
7 7 6 5 2 2 5 3 8 3
8 6 9 6 6 8 9 7 7 9
8
01010000
8 7 7 7 8 7 7 8
4 4 4 2 1 4 4 4
Output
43
36
76
52
----------------------------------------------------------------------------------------------------
