Codeforces Round 179 (Div. 2)


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

Examples
Input
1
1
Output
YES
Input
3
1 1 2
Output
YES
Input
4
7 7 7 7
Output
NO
----------------------------------------------------------------------------------------------------
B. Yaroslav and Two Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
90
09
Output
1
Input
2
11
55
Output
0
Input
5
?????
?????
Output
993531194
----------------------------------------------------------------------------------------------------
C. Greg and Array
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
Output
9 18 17
Input
1 1 1
1
1 1 1
1 1
Output
2
Input
4 3 6
1 2 3 4
1 2 1
2 3 2
3 4 4
1 2
1 3
2 3
1 2
1 3
2 3
Output
5 18 31 20
----------------------------------------------------------------------------------------------------
D. Greg and Graph
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
0
1
Output
0 
Input
2
0 5
4 0
1 2
Output
9 0 
Input
4
0 3 1 1
6 0 400 1
2 4 0 1
1 1 1 0
4 1 2 3
Output
17 23 404 0 
----------------------------------------------------------------------------------------------------
E. Greg and Friends
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 50
50
Output
1
1
Input
3 100
50 50 100
Output
5
2
Input
2 50
50 50
Output
-1
0
----------------------------------------------------------------------------------------------------
