eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Pseudographical recognizer

Pseudographical recognizer

Let us define a pseudographical image to be a rectangular matrix of the characters '\textbf{.}', '\textbf{-}', '\textbf{|}', '\textbf{\textbackslash}', and '\textbf{/}'. The character '\textbf{.}' denotes empty space on the image. A horizontal line segment is given as a set of '\textbf{-}' characters in adjacent cells in the same row of the matrix. A vertical line segment is given as a set of '\textbf{|}' characters in adjacent cells in the same column of the matrix. Similarly, a diagonal line segment is given as a set of '\textbf{/}' or '\textbf{\textbackslash}' characters in adjacent cells in the same diagonal of the matrix. Of course, a line segment going from Northwest to Southeast has to be given using the '\textbf{\textbackslash}' characters and a line segment going from Southwest to Northeast using the '\textbf{/}' characters. Write a program that, given a pseudographical image, determines if it contains exactly one line segment -- horizontal, vertical, or diagonal. \InputFile Input file contains several test cases. The first line contains the number of test cases \textbf{T} (\textbf{1} ≤ \textbf{T} ≤ \textbf{100}). Next follow the descriptions of each test case. The first line of the test case description contains two integers \textbf{N} and \textbf{M} (\textbf{1} ≤ \textbf{N}, \textbf{M} ≤ \textbf{10}), the number of rows and columns of the matrix, respectively. Each of the following \textbf{N} lines of the description contains exactly \textbf{M} symbols '\textbf{.}', '\textbf{-}', '\textbf{|}', '\textbf{\textbackslash}', or '\textbf{/}'. \OutputFile Output file consists of \textbf{T} lines, one line per each test case. This line should contain the word \textbf{CORRECT} if the input image contains exactly one line segment, or the word \textbf{INCORRECT} otherwise.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
1
1 7
......\
Выходные данные #1
CORRECT
Источник ACM Programming Contest 2005, Minsk, October 2005