Pseudographical Recognizer
Time limit1sMemory limit128 MB
Given a small grid of line and dot characters, decide whether the drawn characters form exactly one connected straight segment.
- Level
Easy3 of 10
- Topics
- Implementation, Simulation, Brute force
- Solved
- No attempts yet
Problem
A pseudographical image is a rectangular matrix made up of the characters ., -, |, \, and /.
The character . denotes empty space. A horizontal line segment is a run of - characters in adjacent cells of the same row. A vertical line segment is a run of | characters in adjacent cells of the same column. A diagonal line segment is a run of / or \ characters in adjacent cells along the same diagonal. A segment running from the top-left to the bottom-right (Northwest to Southeast) is drawn with \, and a segment running from the bottom-left to the top-right (Southwest to Northeast) is drawn with /. A single character on its own also counts as a line segment.
Given a pseudographical image, determine whether it contains exactly one line segment — horizontal, vertical, or diagonal.
Input
The input contains several test cases. The first line contains the number of test cases (). The descriptions of the test cases follow. The first line of a test case description contains two integers and () — the number of rows and columns of the matrix. Each of the next lines contains exactly characters, each one of ., -, |, \, or /.
Output
For each test case, print a single line containing CORRECT if the image contains exactly one line segment, or INCORRECT otherwise.