Educational Codeforces Round 87 (Rated for Div. 2)


A. Alarm Clock
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
10 3 6 4
11 3 6 4
5 9 4 10
6 5 2 3
1 1 1 1
3947465 47342 338129 123123
234123843 13 361451236 361451000
Output
27
27
9
-1
1
6471793
358578060125049
----------------------------------------------------------------------------------------------------
B. Ternary String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
123
12222133333332
112233
332211
12121212
333333
31121
Output
3
3
4
4
0
0
4
----------------------------------------------------------------------------------------------------
C1. Simple Polygon Embedding
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
----------------------------------------------------------------------------------------------------
C2. Not So Simple Polygon Embedding
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
5
199
Output
1.931851653
3.196226611
126.687663595
----------------------------------------------------------------------------------------------------
D. Multiset
time limit per test: 1.5 seconds
memory limit per test: 28 megabytes
input: standard input
output: standard output

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

Examples
Input
6 3
2 2 2
3 1
5 4
2 5
Output
YES
112323
Input
5 9
0 2 3
1 2
1 3
1 5
2 3
2 4
2 5
3 4
3 5
4 5
Output
NO
----------------------------------------------------------------------------------------------------
F. Summoning Minions
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5 2
5 3
7 0
5 0
4 0
10 0
2 1
10 100
50 10
5 5
1 5
2 4
3 3
4 2
5 1
Output
4
2 1 -1 5
1
2
5
5 4 3 2 1
----------------------------------------------------------------------------------------------------
G. Find a Gift
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
-
-
-
FIRST
-
5 2
-
-
-
FIRST
-
-
-
SECOND
-
-
-
EQUAL
-
Output
-
-
? 1 1
1
2
-
! 2
-
? 1 1
1
2
-
? 2 3
4 2
1 3 5
-
? 1 1
4
5
-
! 1
----------------------------------------------------------------------------------------------------
