Codeforces Round 233 (Div. 1)


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

Examples
Input
2 3
Output
-1
xoxox
Input
4 0
Output
16
oooo
Input
0 4
Output
-16
xxxx
----------------------------------------------------------------------------------------------------
B. Painting The Wall
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
2 3
4 1
Output
11.7669491886
Input
2 2
1 1
1 2
Output
2.0000000000
Input
1 1
1 1
Output
0.0000000000
----------------------------------------------------------------------------------------------------
C. Tree and Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
Output
1 4 1
1 2 2
2 3 5
3 5 3
2 6 2
6 7 3
4 5
5 6
5 7
----------------------------------------------------------------------------------------------------
D. Instant Messanger
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 9
1
4
1 3
3 4
C 3
A 2 5
O 1
D 1 3
A 1 2
A 4 2
C 2
F 4
C 2
Output
1
2
1
----------------------------------------------------------------------------------------------------
E. Sorting Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 0
1 5 2 4 3
Output
6
Input
5 2
1 0 2 4 0
Output
7
----------------------------------------------------------------------------------------------------
