编程介的小学生 2017-04-06 11:04 采纳率: 20.5%
浏览 875
已采纳

Matrix Transformer

Alice and Bob meet again. This time they play a game named MATRIX TRANSFORMER.

They got an n * n board. Every grid has two positions, UP and DOWN. In this game you can push some amazing buttons to exchange any two rows or any two columns. Alice will win if she got the grids in the main diagonal line all UP.

But Alice finds that for some board, no matter how many times she tries, she cannot get the grids in the main diagonal line all UP. Now she asks you for help, tell her if she can win this board or not.

Input

There are several test cases.
For each test case:
The 1st line contains 1 integer n, indicating the size of the board. (1 ≤ n ≤ 200)
The next n lines, each contains n characters. 'U' indicates the position UP, and 'D' indicates the position DOWN.
There is no separation line between any two test cases.

Output

For each test case, you should print one line. You should print 'YES' if Alice can win, print 'NO' if not.
Sample Input

3
DUD
UDD
DDU
3
DUD
DUD
UDD
Sample Output

YES
NO

  • 写回答

1条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。