Grakn Forces 2020


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

Examples
Input
5
3
1 1 1
2 2 2
3 3 3
4
1 2 1 2
2 1 2 1
3 4 3 4
7
1 3 3 1 1 1 1
2 4 4 3 2 2 4
4 2 2 2 4 4 2
3
1 2 1
2 3 3
3 1 2
10
1 1 1 2 2 2 3 3 3 1
2 2 2 3 3 3 1 1 1 2
3 3 3 1 1 1 2 2 2 3
Output
1 2 3
1 2 1 2
1 3 4 3 2 4 2
1 3 2
1 2 3 1 2 3 1 2 3 2
----------------------------------------------------------------------------------------------------
B. Arrays Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 1
0 0 0 1
3 1
3 3 3
11 3
0 1 2 2 3 3 3 4 4 4 4
5 3
1 2 3 4 5
9 4
2 2 3 5 7 11 13 13 17
10 7
0 1 1 2 3 3 4 5 5 6
Output
-1
1
2
2
2
1
----------------------------------------------------------------------------------------------------
C. Discrete Acceleration
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 10
1 9
1 10
1
5 7
1 2 3 4 6
2 1000000000
413470354 982876160
9 478
1 10 25 33 239 445 453 468 477
Output
3.000000000000000
3.666666666666667
2.047619047619048
329737645.750000000000000
53.700000000000000
----------------------------------------------------------------------------------------------------
D. Searchlights
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
0 0
2 3
Output
3
Input
2 3
1 6
6 1
10 1
1 10
7 7
Output
4
Input
1 2
0 0
0 0
0 0
Output
1
Input
7 3
0 8
3 8
2 7
0 10
5 5
7 0
3 5
6 6
3 11
11 5
Output
6
----------------------------------------------------------------------------------------------------
E. Avoid Rainbow Cycles
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2 3
4 5
2 1 2
2 1 2
2 1 2
Output
11
Input
7 8
3 6 7 9 10 7 239
8 1 9 7 10 2 6 239
3 2 1 3
2 4 1
3 1 3 7
2 4 3
5 3 4 5 6 7
2 5 7
1 8
Output
66
----------------------------------------------------------------------------------------------------
F. Two Different
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
1
1 2
Input
4
Output
2
1 2
3 4
----------------------------------------------------------------------------------------------------
G. Clusterization Counting
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 3 4 6
3 0 2 1
4 2 0 5
6 1 5 0
Output
1 0 1 1 
Input
7
0 1 18 15 19 12 21
1 0 16 13 17 20 14
18 16 0 2 7 10 9
15 13 2 0 6 8 11
19 17 7 6 0 4 5
12 20 10 8 4 0 3
21 14 9 11 5 3 0
Output
1 1 2 3 4 3 1 
----------------------------------------------------------------------------------------------------
H. Rainbow Triples
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1
1
2
0 0
3
0 1 0
6
0 0 1 2 0 0
6
0 1 0 0 1 0
6
0 1 3 2 0 0
6
0 0 0 0 5 0
12
0 1 0 2 2 2 0 0 3 3 4 0
Output
0
0
1
2
1
1
1
2
----------------------------------------------------------------------------------------------------
I. Bitwise Magic
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1 3
1 2 3 4
Output
0 0 0 748683265 0 499122177 0 748683265
----------------------------------------------------------------------------------------------------
