Codeforces Beta Round 50


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

Examples
Input
5 2
1 3
Output
3
Input
10 1
3 6 7 8
Output
10
----------------------------------------------------------------------------------------------------
B. Cutting Jigsaw Puzzle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
ABDC
ABDC
Output
3
2 1
Input
2 6
ABCCBA
ABCCBA
Output
1
2 6
----------------------------------------------------------------------------------------------------
C. First Digit Law
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1 2
50
Output
0.500000000000000
Input
2
1 2
9 11
50
Output
0.833333333333333
----------------------------------------------------------------------------------------------------
D. Writing a Song
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
aba
101
Output
ababa
Input
5 2
a
10001
Output
abbba
Input
6 2
abba
101
Output
No solution
----------------------------------------------------------------------------------------------------
E. Vacuum Сleaner
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 0
1 0
1 1
0 1
Output
0.00000000000000000000
Input
8
1 2
2 1
2 -1
1 -2
-1 -2
-2 -1
-2 1
-1 2
Output
0.50000000000000000000
----------------------------------------------------------------------------------------------------
