MemSQL start[c]up Round 1


A. Square and Rectangles
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 0 2 3
0 3 3 5
2 0 5 2
3 2 5 5
2 2 3 3
Output
YES
Input
4
0 0 2 3
0 3 3 5
2 0 5 2
3 2 5 5
Output
NO
----------------------------------------------------------------------------------------------------
B. Stadium and Games
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
3
4
Input
25
Output
20
Input
2
Output
-1
----------------------------------------------------------------------------------------------------
C. Monsters and Diamonds
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 4
1 3 -1 1 -1
1 2 -1 -1
2 3 -1 3 -1
2 3 -1 -1 -1
3 2 -1 -1
4 2 4 -1
Output
2 -2
3 4
2 2
-1 -1
Input
3 2
1 2 1 -1
2 2 -1 -1
2 3 2 1 -1
Output
-1 -1
2 2
----------------------------------------------------------------------------------------------------
D. Reclamation
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4 9
2 2
3 2
2 3
3 4
3 1
1 3
2 1
1 1
1 4
Output
6
----------------------------------------------------------------------------------------------------
E. The Red Button
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
0 1 0
Input
3
Output
-1
Input
4
Output
0 1 3 2 0
Input
16
Output
0 1 2 4 9 3 6 13 10 5 11 7 15 14 12 8 0
----------------------------------------------------------------------------------------------------
