Codeforces Round 580 (Div. 2)


A. Choose Two Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
20
2
10 20
Output
20 20
Input
3
3 2 2
5
1 5 7 7 9
Output
3 1
Input
4
1 3 5 7
4
7 5 3 1
Output
1 1
----------------------------------------------------------------------------------------------------
B. Make Product Equal One
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
-1 1
Output
2
Input
4
0 0 0 0
Output
4
Input
5
-5 -3 5 3 0
Output
13
----------------------------------------------------------------------------------------------------
C. Almost Equal
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
YES
1 4 5 2 3 6 
Input
4
Output
NO
----------------------------------------------------------------------------------------------------
D. Shortest Cycle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 6 28 9
Output
4
Input
5
5 12 9 16 48
Output
3
Input
4
1 2 4 8
Output
-1
----------------------------------------------------------------------------------------------------
E. Palindromic Paths
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0
1
0
1
1
1
1
Output
? 1 1 1 3
? 1 1 2 3
? 2 1 2 3
? 3 1 3 3
? 2 2 3 3
? 1 2 3 2
? 1 2 3 3
!
100
001
000
----------------------------------------------------------------------------------------------------
F. Almost All
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3
2 1
Output
3 2 1
1 2 2
Input
4
2 4
2 3
2 1
Output
4 2 1
3 2 2
1 2 3
Input
5
1 2
1 3
1 4
2 5
Output
2 1 1
5 2 1
3 1 3
4 1 6
----------------------------------------------------------------------------------------------------
