编程介的小学生 2017-10-20 04:15 采纳率: 20.5%
浏览 672
已采纳

Pseudographical recognizer

Description

Let us define a pseudographical image to be a rectangular matrix of the characters ’.’, ’?’, ’|’, ’\’, and ’/’.

The character ’.’ denotes empty space on the image. A horizontal line segment is given as a set of ’-’ characters in adjacent cells in the same row of the matrix. A vertical line segment is given as a set of ’|’ characters in adjacent cells in the same column of the matrix. Similarly, a diagonal line segment is given as a set of ’/’ or ’\’ 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 ’\’ characters and a line segment going from Southwest to Northeast using the ’/’ characters.

Write a program that, given a pseudographical image, determines if 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 T (1 ≤ T ≤ 100). Next follow the descriptions of each test case. The first line of the test case description contains two integers N and M (1 ≤ N, M ≤ 10), the number of rows and columns of the matrix, respectively. Each of the following N lines of the description contains exactly M symbols ‘.’, ‘?’, ‘|’, ‘\’, or ‘/’.
Output

The output consists of T lines, one line per each test case. This line should contain the word CORRECT if the input image contains exactly one line segment, or the word INCORRECT otherwise.

Sample Input

5
5 5
.....
....
....
....
.....
3 3
/..
./.
../
3 6
.|....
.|.---
.|....
3 3
...
...
...
1 1
/
Sample Output

CORRECT
INCORRECT
INCORRECT
INCORRECT
CORRECT

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-04 13:14
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大