Codeforces Round 212 (Div. 2)


A. Two Semiknights Meet
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K.......
........
........
..#.....
..#..#..
..####..
...##...
........
....K#K#
Output
YES
NO
----------------------------------------------------------------------------------------------------
B. Petya and Staircases
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 5
2 4 8 3 6
Output
NO
Input
10 5
2 4 5 7 9
Output
YES
----------------------------------------------------------------------------------------------------
C. Insertion Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 0 3 1 2
Output
3 2
Input
5
1 2 3 4 0
Output
3 4
----------------------------------------------------------------------------------------------------
D. Fools and Foolproof Roads
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 6 2 2
1 2 2
3 2 1
4 6 20
1 3 8
7 8 3
5 7 2
Output
YES
9 5
1 9
Input
2 0 1 2
Output
NO
Input
2 0 0 2
Output
YES
----------------------------------------------------------------------------------------------------
E. Petya and Pipes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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