Educational Codeforces Round 29


A. Quasi-palindrome
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
131
Output
YES
Input
320
Output
NO
Input
2010200
Output
YES
----------------------------------------------------------------------------------------------------
B. Kayaking
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2 3 4
Output
1
Input
4
1 3 4 6 3 4 100 200
Output
5
----------------------------------------------------------------------------------------------------
C. 1-2-3
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2 1
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
2 2 2
Output
1 9
Input
8 1 1
2 2 1
3 3 1
3 1 3
1 1 1
2 1 1
1 2 3
Output
5 2
Input
5 1 1
1 2 2
2 2 2
2 2 2
1 2 2
2 2 2
2 2 2
Output
0 0
----------------------------------------------------------------------------------------------------
D. Yet Another Array Queries Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3 5
1 2 3 4 5 6
2 1 3
2 3 6
1 1 6
2 2 1 5 3
Output
3 3 1 5 2 
----------------------------------------------------------------------------------------------------
E. Turn Off The TV
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3
4 6
1 7
Output
1
Input
2
0 10
0 10
Output
1
Input
3
1 2
3 4
6 8
Output
-1
Input
3
1 2
2 3
3 4
Output
2
----------------------------------------------------------------------------------------------------
F. Almost Permutation
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 0
Output
3
Input
3 1
1 1 3 2
Output
5
Input
3 2
1 1 3 2
2 1 3 2
Output
9
Input
3 2
1 1 3 2
2 1 3 1
Output
-1
----------------------------------------------------------------------------------------------------
G. Graphic Settings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
3
1
Output
Path
inc 1
inc 1
Input
1
3
2
Output
No
Input
2
3 2
1 1
Output
Cycle
inc 1
inc 1
inc 2
dec 1
dec 1
dec 2
----------------------------------------------------------------------------------------------------
