Codeforces Round 411 (Div. 1)


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

Examples
Input
2
Output
0
Input
10
Output
4
----------------------------------------------------------------------------------------------------
B. Minimum number of steps
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ab
Output
1
Input
aab
Output
3
----------------------------------------------------------------------------------------------------
C. Ice cream coloring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 1
2 2 3
1 2
1 2
2 3
Output
2
1 1 2 
Input
4 5
0
1 1
1 3
3 2 4 5
2 1
3 2
4 3
Output
3
1 1 1 2 3 
----------------------------------------------------------------------------------------------------
D. Expected diameter of a tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 2
1 3
3 1
2 3
Output
-1
2.0000000000
Input
5 2 3
2 4
4 3
4 2
4 1
2 5
Output
-1
2.6666666667
2.6666666667
----------------------------------------------------------------------------------------------------
E. The same permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
NO
Input
1
Output
YES
----------------------------------------------------------------------------------------------------
F. Fake bullions
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1
01
00
5 11000
6 100000
Output
2
Input
5 2 1
00000
10000
11011
11000
11010
2 00
1 1
6 100110
1 0
1 0
Output
5
----------------------------------------------------------------------------------------------------
