Codeforces Global Round 11


A. Avoiding Zero
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
1 -2 3 -4
3
0 0 0
5
1 -1 1 -1 1
6
40 -31 -9 0 13 -40
Output
YES
1 -2 3 -4
NO
YES
1 1 -1 1 -1
YES
-40 13 40 0 -9 -31
----------------------------------------------------------------------------------------------------
B. Chess Cheater
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
5 2
WLWLL
6 5
LLLWWL
7 1
LWLWLWL
15 5
WWWLLLWWWLLLWWW
40 7
LLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWWLWWL
1 0
L
1 1
L
6 1
WLLWLW
Output
7
11
6
26
46
0
1
6
----------------------------------------------------------------------------------------------------
C. The Hard Work of Paparazzi
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 1
11 6 8
Output
0
Input
6 9
1 2 6
7 5 1
8 5 5
10 3 1
12 4 4
13 6 2
17 6 6
20 1 4
21 5 4
Output
4
Input
10 4
1 2 1
5 10 9
13 8 8
15 9 9
Output
1
Input
500 10
69 477 122
73 186 235
341 101 145
372 77 497
390 117 440
494 471 37
522 300 498
682 149 379
821 486 359
855 157 386
Output
3
----------------------------------------------------------------------------------------------------
D. Unshuffling a Deck
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
Output
5
3 + 3
3 ^ 6
3 + 5
3 + 6
8 ^ 9
Input
123
Output
10
123 + 123
123 ^ 246
141 + 123
246 + 123
264 ^ 369
121 + 246
367 ^ 369
30 + 30
60 + 60
120 ^ 121
----------------------------------------------------------------------------------------------------
F. Boring Card Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3 4 9 10 11
Output
9 10 11
6 7 8
2 3 4
1 5 12
Input
5
1 2 3 4 5 9 11 12 13 18 19 20 21 22 23
Output
19 20 21
24 25 26
11 12 13
27 28 29
1 2 3
14 15 16
18 22 23
6 7 8
4 5 9
10 17 30
----------------------------------------------------------------------------------------------------
G. One Billion Shades of Grey
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 7 6
4 0 6
1 1 1
Output
26
Input
3
10 100 1
1 -1 100
10 10 10
Output
396
Input
5
6 6 5 4 4
6 0 0 0 4
7 0 0 0 3
8 0 0 0 2
8 8 1 2 2
Output
34
Input
7
315055237 841510063 581663979 148389224 405375301 243686840 882512379
683199716 -1 -1 0 0 0 346177625
496442279 0 0 0 0 0 815993623
223938231 0 0 -1 0 0 16170511
44132173 0 -1 0 0 0 130735659
212201259 0 0 -1 0 0 166102576
123213235 506794677 467013743 410119347 791447348 80193382 142887538
Output
10129482893
----------------------------------------------------------------------------------------------------
H. Prison Break
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0 0
223 464
0 749
Output
1
Input
3
0 0
2 2
2 4
0 6
Output
1.0823922
Input
4
0 0
7 3
7 4
5 7
0 8
Output
1.130309669
Input
5
0 0
562 248
460 610
281 702
206 723
0 746
Output
1.148649561
Input
7
0 0
412 36
745 180
747 184
746 268
611 359
213 441
0 450
Output
1.134745994
----------------------------------------------------------------------------------------------------
