Russian Code Cup 2016 - Finals [Unofficial Mirror, Div. 1 Only Recommended]


A. Closing ceremony
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
3 3 3 2
1 3
Output
YES
Input
2 2
3 2 3 3
1 2
Output
NO
----------------------------------------------------------------------------------------------------
B. Cactusophobia
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2 4
2 3 1
3 4 2
4 2 3
Output
3
Input
7 9
1 2 1
2 3 4
3 1 5
1 4 5
4 5 2
5 1 6
1 6 4
6 7 6
7 1 3
Output
6
----------------------------------------------------------------------------------------------------
C. Homework
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 3 4
3 3 5
3 3 3
Output
.*.
***
.*.
**.
**.
*..
.*.
***
*..
----------------------------------------------------------------------------------------------------
D. Slalom
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 0
Output
1
Input
4 5 1
2 2 3 4
Output
2
Input
5 5 3
2 2 2 3
4 2 5 2
4 4 4 4
Output
3
----------------------------------------------------------------------------------------------------
E. Cipher
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
42
abcdefghij
jihgfedcba
2
42
aaaaaaaaaa
aaaaaaaaaa
1
2
abcdabcdff
Output
0
58
2
----------------------------------------------------------------------------------------------------
F. Array Covering
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
6 -4 -10 -4 7
Output
11
----------------------------------------------------------------------------------------------------
