Yandex.Algorithm 2011: Round 1


A. Domino
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
yyzz
bccd
bxxd
yyaa
----------------------------------------------------------------------------------------------------
B. Embassy Queue
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1
1 1 1
5
1 1 1 1 1
Output
7
Input
2 1 1
5 1 1
5
1 2 3 3 5
Output
13
----------------------------------------------------------------------------------------------------
C. Petya and Tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
-1 8
1 4
1 12
2 2
2 6
3 10
3 14
1
1
Output
8.0000000000
Input
3
-1 5
1 3
1 7
6
1
2
4
6
8
9
Output
7.0000000000
7.0000000000
7.0000000000
3.0000000000
3.0000000000
3.0000000000
----------------------------------------------------------------------------------------------------
D. Sum of Medians
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
add 4
add 5
add 1
add 2
add 3
sum
Output
3
Input
14
add 1
add 7
add 2
add 5
sum
add 6
add 8
add 9
add 3
add 4
add 10
sum
del 1
sum
Output
5
11
13
----------------------------------------------------------------------------------------------------
E. Guard Towers
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0 0
1 1
Output
0
2
Input
4
0 0
0 1
1 0
1 1
Output
1
4
Input
3
0 0
1000 1000
5000 5000
Output
2000
2
----------------------------------------------------------------------------------------------------
