Codeforces Round 372 (Div. 1)


A. Plus and Square Root
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
14
16
46
Input
2
Output
999999999999999998
44500000000
Input
4
Output
2
17
46
97
----------------------------------------------------------------------------------------------------
B. Complete The Graph
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 13 0 4
0 1 5
2 1 2
3 2 3
1 4 0
4 3 4
Output
YES
0 1 5
2 1 2
3 2 3
1 4 8
4 3 4
Input
2 1 123456789 0 1
0 1 0
Output
YES
0 1 123456789
Input
2 1 999999999 1 0
0 1 1000000000
Output
NO
----------------------------------------------------------------------------------------------------
C. Digit Tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 7
0 1 2
4 2 4
2 0 1
3 0 9
2 5 7
Output
7
Input
5 11
1 2 3
2 0 3
3 0 3
4 3 3
Output
8
----------------------------------------------------------------------------------------------------
D. Create a Maze
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
1 0 0
0 2 0
Output
1 2 1 
Input
4
1 0 0 3
0 0 0 4
Output
0 2 6 4 
Input
6
1 3 2 5 4 6
6 4 5 1 0 0
Output
0 0 0 0 1 1 
Input
4
1 2 3 4
2 3 4 1
Output
0 0 0 1 
----------------------------------------------------------------------------------------------------
