Codeforces Round 710 (Div. 3)


A. Strange Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 1
2 2 3
3 5 11
100 100 7312
1000000 1000000 1000000000000
Output
1
2
9
1174
1000000000000
----------------------------------------------------------------------------------------------------
B. Partial Replacement
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
7 3
.**.***
5 1
..*..
5 2
*.*.*
3 2
*.*
1 1
*
Output
3
1
3
2
1
----------------------------------------------------------------------------------------------------
C. Double-ended Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
a
a
abcd
bc
hello
codeforces
hello
helo
dhjakjsnasjhfksafasd
adjsnasjhfksvdafdser
Output
0
2
13
3
20
----------------------------------------------------------------------------------------------------
D. Epic Transformation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

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

Examples
Input
4
3
1 4 2
1 3 1
2
2 4
2 3
2
1 1000000000
1 1000000000
4
3 10 5 8
2 5 2 4
Output
0
1
999999999
2
----------------------------------------------------------------------------------------------------
G. Maximize the Remaining String
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
codeforces
aezakmi
abacaba
convexhull
swflldjgpaxs
myneeocktxpqjpz
Output
odfrces
ezakmi
cba
convexhul
wfldjgpaxs
myneocktxqjpz
----------------------------------------------------------------------------------------------------
