Educational Codeforces Round 130 (Rated for Div. 2)


A. Parkway Walk
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1
1 2 1
4 5
3 3 5 2
5 16
1 2 3 4 5
Output
3
8
0
----------------------------------------------------------------------------------------------------
B. Promo
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
5 3 1 5 2
3 2
1 1
5 3
Output
8
5
6
----------------------------------------------------------------------------------------------------
C. awoo's Favorite Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
cab
cab
1
a
b
6
abbabc
bbaacb
10
bcaabababc
cbbababaac
2
ba
ab
Output
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
D. Guess The String
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
4
u
2
g
e
s
1
Output
? 2 1 5
? 1 2
? 2 1 2
? 1 1
? 1 3
? 1 4
? 2 4 5
! guess
----------------------------------------------------------------------------------------------------
E. Coloring
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 0
3 0
2 1
Output
9
Input
5
1 2
2 4
3 4
4 4
1 3
Output
240
Input
4
1 0
3 0
2 1
2 0
Output
24
----------------------------------------------------------------------------------------------------
F. Too Many Constraints
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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