
ZOJ Problem Set  3646
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. Output
For each test case, you should print one line.
You should print 'YES' if Alice can win,
print 'NO' if not. Sample Input3 DUD UDD DDU 3 DUD DUD UDD Sample OutputYES NO Author: LI, Tierui 