Codeforces Beta Round 16 (Div. 2 Only)


A. Flag
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
3 3
000
111
222
Output
YES
Input
3 3
000
000
111
Output
NO
Input
3 3
000
111
002
Output
NO
----------------------------------------------------------------------------------------------------
B. Burglar and Matches
time limit per test: 0.5 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
7 3
5 10
2 5
3 6
Output
62
Input
3 3
1 3
2 2
3 1
Output
7
----------------------------------------------------------------------------------------------------
C. Monitor
time limit per test: 0.5 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
----------------------------------------------------------------------------------------------------
D. Logging
time limit per test: 1 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
5
[05:00 a.m.]: Server is started
[05:00 a.m.]: Rescan initialized
[01:13 p.m.]: Request processed
[01:10 p.m.]: Request processed
[11:40 p.m.]: Rescan completed
Output
2
Input
3
[09:00 a.m.]: User logged in
[08:00 a.m.]: User logged in
[07:00 a.m.]: User logged in
Output
3
----------------------------------------------------------------------------------------------------
E. Fish
time limit per test: 3 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
2
0 0.5
0.5 0
Output
0.500000 0.500000 
Input
5
0 1 1 1 1
0 0 0.5 0.5 0.5
0 0.5 0 0.5 0.5
0 0.5 0.5 0 0.5
0 0.5 0.5 0.5 0
Output
1.000000 0.000000 0.000000 0.000000 0.000000 
----------------------------------------------------------------------------------------------------
