Codeforces Round 704 (Div. 2)


A. Three swimmers
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
9 5 4 8
2 6 10 9
10 2 5 10
10 9 9 9
Output
1
4
0
8
----------------------------------------------------------------------------------------------------
B. Card Deck
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
1 2 3 4
5
1 5 2 4 3
6
4 2 5 3 6 1
1
1
Output
4 3 2 1
5 2 4 3 1
6 1 5 3 4 2
1
----------------------------------------------------------------------------------------------------
C. Maximum width
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 3
abbbc
abc
Output
3
Input
5 2
aaaaa
aa
Output
4
Input
5 5
abcdf
abcdf
Output
1
Input
2 2
ab
ab
Output
1
----------------------------------------------------------------------------------------------------
D. Genius's Gambit
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 2 3
Output
Yes
101000
100001
Input
3 2 1
Output
Yes
10100
10010
Input
3 2 5
Output
No
----------------------------------------------------------------------------------------------------
E. Almost Fault-Tolerant Database
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 10 10 100
1 1 1 100
10 100 1 100
Output
Yes
1 10 1 100
Input
10 7
1 1 1 1 1 1 1
1 1 1 1 1 1 2
1 1 1 1 1 2 2
1 1 1 1 2 2 1
1 1 1 2 2 1 1
1 1 2 2 1 1 1
1 2 2 1 1 1 1
2 2 1 1 1 1 1
2 1 1 1 1 1 1
1 1 1 1 1 1 1
Output
Yes
1 1 1 1 1 1 1
Input
2 5
2 2 1 1 1
1 1 2 2 2
Output
No
----------------------------------------------------------------------------------------------------
