Codeforces Round 556 (Div. 2)


A. Stock Arbitraging
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 11
4 2 5
4 4 5 4
Output
26
Input
2 2 50
5 7
4 2
Output
50
----------------------------------------------------------------------------------------------------
B. Tiling Challenge
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
#.#
...
#.#
Output
YES
Input
4
##.#
#...
####
##.#
Output
NO
Input
5
#.###
....#
#....
###.#
#####
Output
YES
Input
5
#.###
....#
#....
....#
#..##
Output
NO
----------------------------------------------------------------------------------------------------
C. Prefix Sum Primes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 1 2 1
Output
1 1 1 2 2
Input
9
1 1 2 1 1 1 2 1 1
Output
1 1 1 2 1 1 1 2 1
----------------------------------------------------------------------------------------------------
D. Three Religions
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 8
abdabc
+ 1 a
+ 1 d
+ 2 b
+ 2 c
+ 3 a
+ 3 b
+ 1 c
- 2
Output
YES
YES
YES
YES
YES
YES
NO
YES
Input
6 8
abbaab
+ 1 a
+ 2 a
+ 3 a
+ 1 b
+ 2 b
+ 3 b
- 1
+ 2 z
Output
YES
YES
YES
YES
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
E. Tree Generator™
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
(((())))
4 5
3 4
5 6
3 6
2 5
Output
4
3
3
2
4
4
Input
6 4
(((())()))
6 7
5 4
6 4
7 4
Output
4
4
4
5
3
----------------------------------------------------------------------------------------------------
