Codeforces Round 614 (Div. 1)


A. NEKO's Maze Game
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
2 3
1 4
2 4
2 3
1 4
Output
Yes
No
No
No
Yes
----------------------------------------------------------------------------------------------------
B. Aroma's Search
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 2 3 1 0
2 4 20
Output
3
Input
1 1 2 3 1 0
15 27 26
Output
2
Input
1 1 2 3 1 0
2 2 1
Output
0
----------------------------------------------------------------------------------------------------
C. Xenon's Attack on the Gangs
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
2 3
Output
3
Input
5
1 2
1 3
1 4
3 5
Output
10
----------------------------------------------------------------------------------------------------
D. Chaotic V.
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 4
Output
5
Input
4
3 1 4 4
Output
6
Input
4
3 1 4 1
Output
6
Input
5
3 1 4 1 5
Output
11
----------------------------------------------------------------------------------------------------
E. Rin and The Unknown Flower
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
4
2 1 2
1 2
0
1
Output
? C
? CH
? CCHO
! CCHH
Input
2
5
0
2 2 3
1
8
1 5
1 5
1 3
2 1 2
1
Output
? O
? HHH
! CHHHH
? COO
? COOH
? HCCOO
? HH
! HHHCCOOH
----------------------------------------------------------------------------------------------------
F. Nora's Toy Boxes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 6 8
Output
2
Input
5
2 3 4 9 12
Output
4
Input
4
5 7 2 9
Output
1
----------------------------------------------------------------------------------------------------
