Codeforces Round 185 (Div. 1)


A. The Closest Pair
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
Output
0 0
0 1
1 0
1 1
Input
2 100
Output
no solution
----------------------------------------------------------------------------------------------------
B. Cats Transport
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 6 2
1 3 5
1 0
2 1
4 9
1 10
2 10
3 12
Output
3
----------------------------------------------------------------------------------------------------
C. Fetch the Treasure
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 3 5 2
5 50
7 60
8 100
2 2 5
3
1 3
3
3
Output
55
100
50
----------------------------------------------------------------------------------------------------
D. Interval Cubing
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1 2 3 4 5 6 7 8
5
1 2 5
2 2 5
1 2 5
2 3 6
1 4 7
Output
14
224
2215492
----------------------------------------------------------------------------------------------------
E. Biologist
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 9
0 1 1 1 0
1 8 6 2 3
0 7 3 3 2 1 1
1 8 1 5 1
1 0 3 2 1 4 1
0 8 3 4 2 1 0
1 7 2 4 1 1
Output
2
Input
5 5 8
1 0 1 1 1
6 5 4 2 8
0 6 3 2 3 4 0
0 8 3 3 2 4 0
0 0 3 3 4 1 1
0 10 3 4 3 1 1
0 4 3 3 4 1 1
Output
16
----------------------------------------------------------------------------------------------------
