Codeforces Round 580 (Div. 1)


A. 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
----------------------------------------------------------------------------------------------------
B. 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
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. Expected Value Again
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
Output
333333336
Input
1 5
Output
0
Input
100 1
Output
9801
Input
10 10
Output
412377396
----------------------------------------------------------------------------------------------------
F. Beauty of a Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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