Educational Codeforces Round 32


A. Local Extrema
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
LDUR
Output
4
Input
5
RRRUU
Output
0
Input
6
LLRRRR
Output
4
----------------------------------------------------------------------------------------------------
C. K-Dominant Character
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abacaba
Output
2
Input
zzzzz
Output
1
Input
abcde
Output
3
----------------------------------------------------------------------------------------------------
D. Almost Identity Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
Output
1
Input
4 2
Output
7
Input
5 3
Output
31
Input
5 4
Output
76
----------------------------------------------------------------------------------------------------
E. Maximum Subsequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
5 2 4 1
Output
3
Input
3 20
199 41 299
Output
19
----------------------------------------------------------------------------------------------------
F. Connecting Vertices
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 1
0 0 1
1 1 0
Output
1
Input
4
0 1 1 1
1 0 1 1
1 1 0 1
1 1 1 0
Output
12
Input
3
0 0 0
0 0 1
0 1 0
Output
0
----------------------------------------------------------------------------------------------------
G. Xor-MST
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
8
Input
4
1 2 3 4
Output
8
----------------------------------------------------------------------------------------------------
