Codeforces Round 109 (Div. 1)


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

Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
----------------------------------------------------------------------------------------------------
B. Colliders
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 10
+ 6
+ 10
+ 5
- 10
- 5
- 6
+ 10
+ 3
+ 6
+ 3
Output
Success
Conflict with 6
Success
Already off
Success
Success
Success
Success
Conflict with 10
Already on
----------------------------------------------------------------------------------------------------
C. Double Profiles
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2
2 3
1 3
Output
3
Input
3 0
Output
3
Input
4 1
1 3
Output
2
----------------------------------------------------------------------------------------------------
D. Flatland Fencing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 2 0 4
Output
FIRST
2
Input
0 2 1 1
Output
SECOND
Input
0 2 0 1
Output
DRAW
----------------------------------------------------------------------------------------------------
E. Martian Colony
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
0.00 0.000
0.0 8.00
6 8.00
Output
78.5398163397
Input
4 1000
0.0 0.0
0 2.00
2.00 2
2.0 0.00
Output
4.0026666140
Input
4 5
3.00 0.0
-3 0.00
0.000 1
0.0 -1.00
Output
8.1750554397
----------------------------------------------------------------------------------------------------
