Educational Codeforces Round 27


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

Examples
Input
2
1 3 2 4
Output
YES
Input
1
3 3
Output
NO
----------------------------------------------------------------------------------------------------
B. Luba And The Ticket
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
000000
Output
0
Input
123456
Output
2
Input
111000
Output
1
----------------------------------------------------------------------------------------------------
C. Two TVs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
2 3
4 5
Output
YES
Input
4
1 2
2 3
2 3
1 2
Output
NO
----------------------------------------------------------------------------------------------------
D. Driving Test
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
1 100
3 70
4
2
3 120
5
3 120
6
1 150
4
3 300
Output
2
Input
5
1 100
3 200
2
4
5
Output
0
Input
7
1 20
2
6
4
6
6
2
Output
2
----------------------------------------------------------------------------------------------------
E. Fire in the City
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 7 3
1 2
2 1
5 5
Output
3
Input
10 5 1
3 3
Output
2
----------------------------------------------------------------------------------------------------
F. Guards In The Storehouse
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 3
.x.
Output
3
Input
2 2
xx
xx
Output
1
Input
2 2
..
..
Output
10
Input
3 1
x
.
x
Output
2
----------------------------------------------------------------------------------------------------
G. Shortest Path Problem?
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2 3
1 3 2
3 2 0
Output
2
Input
2 2
1 1 3
1 2 3
Output
0
----------------------------------------------------------------------------------------------------
