Codeforces Round 612 (Div. 1)


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

Examples
Input
5
0 5 0 2 3
Output
2
Input
7
1 0 0 5 0 0 2
Output
1
----------------------------------------------------------------------------------------------------
B. Numbers on Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 0
0 2
2 0
Output
YES
1 2 1 
Input
5
0 1
1 3
2 1
3 0
2 0
Output
YES
2 3 2 1 2
----------------------------------------------------------------------------------------------------
C1. Madhouse (Easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a
aa
a
cb
b
c
c
Output
? 1 2
? 3 4
? 4 4
! aabc
----------------------------------------------------------------------------------------------------
C2. Madhouse (Hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a
aa
a
cb
b
c
c
Output
? 1 2
? 3 4
? 4 4
! aabc
----------------------------------------------------------------------------------------------------
D. LCC
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1 100
3 1 0
Output
1
Input
3
7 10 0
9 4 86
14 5 100
Output
0
Input
4
6 4 50
11 25 50
13 16 50
15 8 50
Output
150902884
----------------------------------------------------------------------------------------------------
E. Fedya the Potter Strikes Back
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
a 1
a 0
y 3
y 5
v 4
u 6
r 8
Output
1
2
4
5
7
9
12
Input
4
a 2
y 2
z 0
y 2
Output
2
2
2
2
Input
5
a 7
u 5
t 3
s 10
s 11
Output
7
9
11
12
13
----------------------------------------------------------------------------------------------------
F. Harry The Potter
time limit per test: 9 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
1 10 100
Output
3
Input
3
5 3 -2
Output
2
Input
1
0
Output
0
----------------------------------------------------------------------------------------------------
