120 - ZOJ Monthly, September 2012 - C
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.
There are several test cases.
For each test case, you should print one line.
You should print 'YES' if Alice can win,
print 'NO' if not.
3 DUD UDD DDU 3 DUD DUD UDD
Author: LI, Tierui