Codeforces Global Round 21


A. NIT orz!
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2 3
3 4
5 5
0 2 4 6 8
1 9
10
5 7
7 15 30 29 27
3 39548743
10293834 10284344 13635445
Output
7
13
11
31
48234367
----------------------------------------------------------------------------------------------------
B. NIT Destroys the Universe
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
0 0 0 0
5
0 1 2 3 4
7
0 2 3 0 1 2 0
1
1000000000
Output
0
1
2
1
----------------------------------------------------------------------------------------------------
C. Fishingprince Plays With Array
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
5 2
1 2 2 4 2
4
1 4 4 2
6 2
1 2 2 8 2 2
2
1 16
8 3
3 3 3 3 3 3 3 3
4
6 6 6 6
8 3
3 9 6 3 12 12 36 12
16
9 3 2 2 2 3 4 12 4 12 4 12 4 12 4 4
8 3
3 9 6 3 12 12 36 12
7
12 2 4 3 4 12 56
Output
Yes
Yes
No
Yes
No
----------------------------------------------------------------------------------------------------
D. Permutation Graph
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1
1
2
1 2
5
1 4 2 3 5
5
2 1 5 3 4
10
7 4 8 1 6 10 3 5 2 9
Output
0
1
1
4
6
----------------------------------------------------------------------------------------------------
E. Placing Jinas
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2 2 0
Output
5
Input
10
12 11 8 8 6 6 6 5 3 2 1
Output
2596
----------------------------------------------------------------------------------------------------
F. Tree Recovery
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2
00
2
10
3
001 000
000
3
001 010
000
5
00000 01001 00000 01100
00000 10000 00000
00000 11010
00000
Output
Yes
1 2
No
Yes
1 3
2 3
No
Yes
1 2
1 4
2 3
2 5
----------------------------------------------------------------------------------------------------
G. Fishingprince Plays With Array Again
time limit per test: 6 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 2
3 1 1 4
2 1 4
1 1 1
2 1 3
Output
3.500000000000000
1.000000000000000
----------------------------------------------------------------------------------------------------
H. Maximum Product?
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
-1 2 4
Output
10
Input
3 1
1 1 1
Output
7
Input
10 4
-24 -41 9 -154 -56 14 18 53 -7 120
Output
225905161
Input
15 5
0 0 2 -2 2 -2 3 -3 -3 4 5 -4 -4 4 5
Output
18119684
----------------------------------------------------------------------------------------------------
