Codeforces Round 612 (Div. 2)


A. Angry Students
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
4
PPAP
Output
1
Input
3
12
APPAPPPAPPPP
3
AAP
3
PPA
Output
4
1
0
----------------------------------------------------------------------------------------------------
B. Hyperset
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
SET
ETS
TSE
Output
1
Input
3 4
SETE
ETSE
TSES
Output
0
Input
5 4
SETT
TEST
EEET
ESTE
STES
Output
2
----------------------------------------------------------------------------------------------------
C. Garland
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 5 0 2 3
Output
2
Input
7
1 0 0 5 0 0 2
Output
1
----------------------------------------------------------------------------------------------------
D. Numbers on Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 0
0 2
2 0
Output
YES
1 2 1 
Input
5
0 1
1 3
2 1
3 0
2 0
Output
YES
2 3 2 1 2
----------------------------------------------------------------------------------------------------
E1. Madhouse (Easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a
aa
a
cb
b
c
c
Output
? 1 2
? 3 4
? 4 4
! aabc
----------------------------------------------------------------------------------------------------
E2. Madhouse (Hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a
aa
a
cb
b
c
c
Output
? 1 2
? 3 4
? 4 4
! aabc
----------------------------------------------------------------------------------------------------
F. LCC
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1 100
3 1 0
Output
1
Input
3
7 10 0
9 4 86
14 5 100
Output
0
Input
4
6 4 50
11 25 50
13 16 50
15 8 50
Output
150902884
----------------------------------------------------------------------------------------------------
