Codeforces Round 567 (Div. 2)


A. Chunga-Changa
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 4 3
Output
3 1
Input
6 8 2
Output
7 0
----------------------------------------------------------------------------------------------------
B. Split a Number
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
1234567
Output
1801
Input
3
101
Output
11
----------------------------------------------------------------------------------------------------
C. Flag
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 3
aaa
bbb
ccb
ddd
Output
6
Input
6 1
a
a
b
b
c
c
Output
1
----------------------------------------------------------------------------------------------------
D. Irrigation
time limit per test: 2.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 4 10
3 1 1 1 2 2
7
8
9
10
11
12
13
14
15
16
Output
4
3
4
2
3
4
1
2
3
4
Input
4 5 4
4 4 5 1
15
9
13
6
Output
5
3
3
3
----------------------------------------------------------------------------------------------------
E1. A Story of One Country (Easy)
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
0 0 1 2
0 2 1 3
1 0 2 1
1 1 2 3
Output
YES
Input
4
0 0 2 1
1 2 3 3
2 0 3 2
0 1 1 3
Output
NO
----------------------------------------------------------------------------------------------------
E2. A Story of One Country (Hard)
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
0 0 1 2
0 2 1 3
1 0 2 1
1 1 2 3
Output
YES
Input
4
0 0 2 1
1 2 3 3
2 0 3 2
0 1 1 3
Output
NO
----------------------------------------------------------------------------------------------------
