Codeforces Round 292 (Div. 1)


A. Drazil and Factorial
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1234
Output
33222
Input
3
555
Output
555
----------------------------------------------------------------------------------------------------
B. Drazil and Tiles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
...
.*.
...
Output
Not unique
Input
4 4
..**
*...
*.**
....
Output
<>**
*^<>
*v**
<><>
Input
2 4
*..*
....
Output
*<>*
<><>
Input
1 1
.
Output
Not unique
Input
1 1
*
Output
*
----------------------------------------------------------------------------------------------------
C. Drazil and Park
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 3
2 2 2 2 2
3 5 2 1 4
1 3
2 2
4 5
Output
12
16
18
Input
3 3
5 1 4
5 1 4
3 3
2 2
1 1
Output
17
22
11
----------------------------------------------------------------------------------------------------
D. Drazil and Morning Exercise
time limit per test: 3.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3
2 3 4
4 5 3
3 4 2
5
1 2 3 4 5
Output
1
3
3
3
5
Input
12
5 9 3
2 1 7
11 7 2
6 5 5
2 5 3
6 7 2
1 4 4
8 5 7
1 3 8
11 12 3
10 8 2
10
13 14 14 13 13 4 6 7 2 1
Output
10
10
10
10
10
3
3
5
2
1
----------------------------------------------------------------------------------------------------
E. Drazil and His Happy Friends
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
0
1 0
Output
4
Input
2 4
1 0
1 2
Output
-1
Input
2 3
1 0
1 1
Output
2
Input
99999 100000
2 514 415
2 50216 61205
Output
4970100515
----------------------------------------------------------------------------------------------------
