Codeforces Round 607 (Div. 1)


A. Cut and Paste
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
231
7
2323
6
333
24
133321333
Output
25
1438
1101
686531475
----------------------------------------------------------------------------------------------------
B. Beingawesomeism
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7 8
AAPAAAAA
PPPPAAAA
PPPPAAAA
APAAPPPP
APAPPAPP
AAAAPPAP
AAAAPPAA
6 5
AAAAA
AAAAA
AAPAA
AAPAP
AAAPP
AAAPP
4 4
PPPP
PPPP
PPPP
PPPP
3 4
PPPP
PAAP
PPPP
Output
2
1
MORTAL
4
----------------------------------------------------------------------------------------------------
C. Jeremy Bearimy
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1 2 3
3 2 4
2 4 3
4 5 6
5 6 5
2
1 2 1
1 3 2
1 4 3
Output
15 33
6 6
----------------------------------------------------------------------------------------------------
D. Miss Punyverse
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
4 3
10 160 70 50
70 111 111 0
1 2
2 3
3 4
2 1
143 420
214 349
2 1
Output
2
0
----------------------------------------------------------------------------------------------------
E. Kirchhoff's Current Loss
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 *
1 (* S *)
1 (* P (* S *))
Output
REVOLTING 5
REVOLTING 1 0
REVOLTING 2 1 1
----------------------------------------------------------------------------------------------------
F. Intergalactic Sliding Puzzle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1 2 3 5 6 E 7
8 9 10 4 11 12 13
11
34 45 6 22 16 43 38 44 5 4 41 14 7 29 28 19 9 18 42 8 17 33 1
E 15 40 36 31 24 10 2 21 11 32 23 30 27 35 25 13 12 39 37 26 20 3
Output
SURGERY COMPLETE
IR
R SrS
S rr
I lldll
DONE
SURGERY FAILED
----------------------------------------------------------------------------------------------------
