Educational Codeforces Round 38 (Rated for Div. 2)


A. Word Correction
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
weird
Output
werd
Input
4
word
Output
word
Input
5
aaeaa
Output
a
----------------------------------------------------------------------------------------------------
B. Run For Your Prize
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 9
Output
8
Input
2
2 999995
Output
5
----------------------------------------------------------------------------------------------------
C. Constructing Tests
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
21
0
1
Output
5 2
1 1
-1
----------------------------------------------------------------------------------------------------
D. Buy a Ticket
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 2 4
2 3 7
6 20 1 25
Output
6 14 1 25 
Input
3 3
1 2 1
2 3 1
1 3 1
30 10 20
Output
12 10 12 
----------------------------------------------------------------------------------------------------
E. Max History
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 3
Output
1
Input
3
1 1 2
Output
4
----------------------------------------------------------------------------------------------------
F. Erasing Substrings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
adcbca
Output
aba
Input
abacabadabacaba
Output
aabacaba
----------------------------------------------------------------------------------------------------
G. Shortest Path Queries
time limit per test: 3.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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