Educational Codeforces Round 37 (Rated for Div. 2)


A. Water The Garden
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 1
3
3 3
1 2 3
4 1
1
Output
3
1
4
----------------------------------------------------------------------------------------------------
B. Tea Queue
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
1 3
1 4
3
1 5
1 1
2 3
Output
1 2 
1 0 2 
----------------------------------------------------------------------------------------------------
C. Swap Adjacent Elements
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 3 5
2 3
Output
YES
1 2 1
Input
2 3 4
2 3
Output
NO
Input
5 2 0
1 3 5 7 9
Output
YES
2 2 1
3 3 1
4 4 1
5 5 1
----------------------------------------------------------------------------------------------------
E. Connected Components?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
1 2
3 4
3 2
4 2
2 5
Output
2
1 4 
----------------------------------------------------------------------------------------------------
F. SUM and REPLACE
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 6
6 4 1 10 3 2 4
2 1 7
2 4 5
1 3 5
2 4 4
1 5 7
2 1 7
Output
30
13
4
22
----------------------------------------------------------------------------------------------------
G. List Of Integers
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 22 1
7 22 2
7 22 3
Output
9
13
15
Input
5
42 42 42
43 43 43
44 44 44
45 45 45
46 46 46
Output
187
87
139
128
141
----------------------------------------------------------------------------------------------------
