Codeforces Round 769 (Div. 2)


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

Examples
Input
4
1
1
2
10
2
01
4
1010
Output
YES
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Roof Construction
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
3
5
10
Output
0 1
2 0 1
3 2 1 0 4
4 6 3 2 0 8 9 1 7 5
----------------------------------------------------------------------------------------------------
C. Strange Test
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3
5 8
2 5
3 19
56678 164422
Output
1
3
2
1
23329
----------------------------------------------------------------------------------------------------
D. New Year Concert
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1
Output
1 
Input
3
1 4 2
Output
1 1 2 
Input
7
2 12 4 8 18 3 6
Output
0 1 1 1 2 2 2 
----------------------------------------------------------------------------------------------------
E1. Distance Tree (easy version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 2
2 3
1 4
2
1 2
7
1 2
1 3
3 4
3 5
3 6
5 7
Output
1 2 2 2 
1 1 
2 2 3 3 3 3 3 
----------------------------------------------------------------------------------------------------
E2. Distance Tree (hard version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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