Codeforces Round 369 (Div. 2)


A. Bus to Udayland
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
OO|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
Output
YES
++|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
Input
4
XO|OX
XO|XX
OX|OX
XX|OX
Output
NO
Input
5
XX|XX
XX|XX
XO|OX
XO|OO
OX|XO
Output
YES
XX|XX
XX|XX
XO|OX
XO|++
OX|XO
----------------------------------------------------------------------------------------------------
B. Chris and Magic Square
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 0 2
3 5 7
8 1 6
Output
9
Input
4
1 1 1 1
1 1 0 1
1 1 1 1
1 1 1 1
Output
1
Input
4
1 1 1 1
1 1 0 1
1 1 2 1
1 1 1 1
Output
-1
----------------------------------------------------------------------------------------------------
C. Coloring Trees
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
2 3 1
Output
6
Input
4
2 1 1 1
Output
8
Input
5
2 4 2 5 3
Output
28
----------------------------------------------------------------------------------------------------
E. ZS and The Birthday Paradox
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
1 8
Input
1 3
Output
1 1
Input
4 3
Output
23 128
----------------------------------------------------------------------------------------------------
