CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes!)


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

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

Examples
Input
4
4 5
4 2 2 7
5 4
1 9 1 3 4
2 17
17 0
2 17
18 18
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
C. Make Equal With Mod
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
2 5 6 8
3
1 1 1
5
4 1 7 0 8
4
5 9 17 5
Output
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
D. K-good
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
4
6
15
20
Output
-1
-1
3
3
5
----------------------------------------------------------------------------------------------------
E. Equal Tree Sums
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
1 2
1 3
3 4
3 5
3
1 2
1 3
Output
-3 5 1 2 2
1 1 1
----------------------------------------------------------------------------------------------------
F. Parametric MST
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
1 0
2
-1 1
3
1 -1 -2
3
3 -1 -2
4
1 2 3 -4
Output
INF
-1
INF
-6
-18
----------------------------------------------------------------------------------------------------
G. Cycle Palindrome
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 2 2 1
3
1 2 1
7
1 3 3 3 1 2 2
Output
YES
3 1 4 2 
NO
YES
5 3 7 2 6 4 1 
----------------------------------------------------------------------------------------------------
H. Equal LCM Subsets
time limit per test: 10 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 4
5 6 7
2 8 9 10
4 4
5 6 7 8
2 3 4 9
1 3
1
1 2 3
5 6
3 4 9 7 8
2 15 11 14 20 12
Output
NO
YES
1 2
6
2 3
YES
1 1
1
1
YES
3 2
3 7 4
12 14
----------------------------------------------------------------------------------------------------
I. Neighbour Ordering
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 6
0 1
0 2
1 2
2 3
3 4
4 1
2 1
0 1
6 10
0 1
2 0
0 3
0 4
1 2
1 4
2 3
2 5
3 5
4 5
Output
YES
1 2 
4 2 0 
0 1 3 
2 4 
3 1 
YES
1 
0 
NO
----------------------------------------------------------------------------------------------------
