Codeforces Round 583 (Div. 1 + Div. 2, based on Olympiad of Metropolises)


A. Optimal Currency Exchange
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
100
60
70
Output
40
Input
410
55
70
Output
5
Input
600
60
70
Output
0
----------------------------------------------------------------------------------------------------
B. Badges
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
6
3
Output
4
Input
5
3
5
Output
4
----------------------------------------------------------------------------------------------------
C. Bad Sequence
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
)(
Output
Yes
Input
3
(()
Output
No
Input
2
()
Output
Yes
Input
10
)))))(((((
Output
No
----------------------------------------------------------------------------------------------------
D. Treasure Island
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 2
..
..
Output
2
Input
4 4
....
#.#.
....
.#..
Output
1
Input
3 4
....
.##.
....
Output
2
----------------------------------------------------------------------------------------------------
E. Petya and Construction Set
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2 2
Output
1 6
2 6
3 5
3 6
4 5
Input
4
2 2 2 1
Output
1 6
1 7
2 6
3 5
3 6
4 5
7 8
Input
6
2 2 2 2 2 2
Output
1 3
2 3
3 5
4 5
5 7
6 7
7 12
8 12
9 11
9 12
10 11
Input
2
1 1
Output
1 2
1 4
3 4
----------------------------------------------------------------------------------------------------
F. Employment
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10 3
1 5 5
10 4 6
Output
3
1 2 3 
Input
10 3
1 4 8
8 3 6
Output
4
2 3 1 
----------------------------------------------------------------------------------------------------
G. Feeling Good
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 2 6
1 1 1
2 2 2
2 1 1
1 2 2
2 2 2
1 1 1
Output
-1
1 1 2 2
-1
-1
-1
1 1 2 2
Input
4 3 9
2 2 3
4 1 2
2 1 3
3 2 2
3 1 3
1 2 2
4 2 3
1 1 3
3 1 3
Output
-1
2 1 4 3
-1
2 1 3 2
3 2 4 3
1 1 2 2
1 1 2 2
-1
2 1 3 2
----------------------------------------------------------------------------------------------------
H. Tiles Placement
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1 3
2 3
3 4
4 5
5 6
5 7
Output
Yes
1 1 2 3 4 1 1
Input
7 3
1 3
2 3
3 4
4 5
5 6
5 7
Output
No
----------------------------------------------------------------------------------------------------
