LCC/Moose '20 Contest 5 S2 - Facials!

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

After years of developement, Nayaab has finally created the world's first fully automatic facial machine! The only problem being she forgot to program it to check whether or not it actually sees a face.

While the device does have a camera, Nayaab informs you that the camera is very limited. It can only caputure a W by H grainy image. Because of this, faces should be rejected if one of their features (eye or mouth) has an erroneous adjacent black pixel.

She then proceeds to hand you the following schematic that describes a face:

Where the eyes are always 1 pixel in height and width, and the mouth is always 1 pixel in height.

Luckily you only have to check for the two eyes and a straight mouth for faces and you can assume that faces are always vertical.

Can you write a program to detect faces for Nayaab?

Input Specification

The first line consists of two integers, W, H (1 \le W, H \le 1000), the width and height of the image respectivly.

The next H lines each contain W characters. Each character will either be ., representing a white pixel, or # representing a black pixel in the image.

Output Specification

Output OK if only one face is found.

Otherwise output ABORT on the first line and on a second line output the number of faces detected.

Sample Input 1

10 10
..........
..........
...######.
..########
.##..#.###
....#...##
...#.....#
..#.......
######....
#####.....

Sample Output 1

ABORT
0

Sample Input 2

10 10
..........
.#........
..#...#...
..........
.######...
........#.
..........
....#.....
....#.....
..........

Sample Output 2

OK

Comments

There are no comments at the moment.