Codeforces Round 849 (Div. 4)


A. Codeforces Checking
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
a
b
c
d
e
f
g
h
i
j
Output
NO
NO
YES
YES
YES
YES
NO
NO
NO
NO
----------------------------------------------------------------------------------------------------
B. Following Directions
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
7
UUURDDL
2
UR
8
RRRUUDDD
3
LLL
4
DUUR
5
RUDLL
11
LLLLDDRUDRD
Output
YES
YES
NO
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
C. Prepend and Append
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
3
100
4
0111
5
10101
6
101010
7
1010110
1
1
2
10
2
11
10
1011011010
Output
1
2
5
0
3
1
0
2
4
----------------------------------------------------------------------------------------------------
D. Distinct Split
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
aa
7
abcabcd
5
aaaaa
10
paiumoment
4
aazz
Output
2
7
2
10
3
----------------------------------------------------------------------------------------------------
E. Negatives and Positives
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
-1 -1 -1
5
1 5 -5 0 2
3
1 2 3
6
-1 10 9 8 7 6
2
-1 -1
Output
1
13
6
39
2
----------------------------------------------------------------------------------------------------
F. Range Update Point Query
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 8
1 420 69 1434 2023
1 2 3
2 2
2 3
2 4
1 2 5
2 1
2 3
2 5
2 3
9999 1000
1 1 2
2 1
2 2
1 1
1
2 1
Output
6
15
1434
1
6
7
36
1
1
----------------------------------------------------------------------------------------------------
G1. Teleporters (Easy Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
5 6
1 1 1 1 1
8 32
100 52 13 6 9 4 100 35
1 1
5
4 5
4 3 2 1
5 9
2 3 1 4 1
5 8
2 3 1 4 1
4 3
2 3 4 1
4 9
5 4 3 3
2 14
7 5
5 600000000
500000000 400000000 300000000 200000000 100000000
Output
2
2
0
1
2
2
1
1
1
2
----------------------------------------------------------------------------------------------------
G2. Teleporters (Hard Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
5 6
1 1 1 1 1
8 32
100 52 13 6 9 4 100 35
1 1
5
4 5
4 3 2 1
5 9
2 3 1 4 1
5 8
2 3 1 4 1
4 3
2 3 4 1
4 9
5 4 3 3
2 14
7 5
5 600000000
500000000 400000000 300000000 200000000 100000000
Output
2
3
0
1
3
2
1
1
2
2
----------------------------------------------------------------------------------------------------
