School Team Contest 2 (Winter Computer School 2010/11)


A. Indian Summer
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
birch yellow
maple red
birch yellow
maple yellow
maple green
Output
4
Input
3
oak yellow
oak yellow
oak yellow
Output
1
----------------------------------------------------------------------------------------------------
B. Cola
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 5 5 5
Output
9
Input
3 0 0 2
Output
0
----------------------------------------------------------------------------------------------------
C. Holidays
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 5
1 2
3 3
4 6
7 7
8 10
Output
OK
Input
10 5
1 2
2 3
4 5
7 8
9 10
Output
2 2
Input
10 5
1 2
3 3
5 7
7 7
7 10
Output
4 0
----------------------------------------------------------------------------------------------------
D. Hyperdrive
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 0 0
0 0 1
0 1 0
1 0 0
Output
1.7071067812
----------------------------------------------------------------------------------------------------
E. Anfisa the Monkey
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 5
abrakadabra
Output
ab
rakad
abra
Input
4 1 2
abrakadabra
Output
No solution
----------------------------------------------------------------------------------------------------
F. BerPaint
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
6
1 1 1 3
1 3 3 3
3 3 3 1
3 1 1 1
1 3 3 1
1 1 3 3
2
2 1 red
2 2 blue
Output
blue 0.00000000
white 20.00000000
Input
5 5
5
1 1 2 2
2 2 4 2
4 2 4 4
4 4 2 4
2 4 2 2
2
3 3 black
3 3 green
Output
green 4.00000000
white 21.00000000
Input
7 4
9
1 2 2 3
2 3 3 2
3 2 2 1
2 1 1 2
3 2 4 2
4 2 5 3
5 3 6 2
6 2 5 1
5 1 4 2
2
2 2 black
2 2 red
Output
red 2.00000000
white 26.00000000
----------------------------------------------------------------------------------------------------
G. Shooting Gallery
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 4 1 4 1
2 5 2 6 2
4
0 0
3 3
4 5
3 5
Output
0
1
2
0
----------------------------------------------------------------------------------------------------
H. Phone Number
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12345
Output
48
Input
09
Output
15
----------------------------------------------------------------------------------------------------
I. Toys
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
5
{1,2,3}
{1,2},{3}
{1},{2,3}
{1},{2},{3}
{1,3},{2}
----------------------------------------------------------------------------------------------------
J. Triminoes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 10
.w.wbw.wbw
wbwbw.w.w.
bw.wbwbwbw
w.wbw.wbwb
...wbw.w.w
..wbw.wbw.
Output
YES
.a.aaa.ccc
baccc.c.a.
ba.dddcbab
b.aaa.cbab
...bbb.b.b
..ccc.ddd.
Input
2 2
wb
bw
Output
NO
Input
1 3
wbw
Output
YES
bbb
Input
1 3
...
Output
YES
...
----------------------------------------------------------------------------------------------------
