Solution - 1749A - Cowardly Rooks - C++ solution codeforces
- Get link
- X
- Other Apps
Cowardly Rooks solution codeforces
There's a chessboard of size
- no two rooks occupy the same cell;
- no two rooks attack each other.
A rook attacks all cells that are in its row or column.
Is it possible to move exactly one rook (you can choose which one to move) into a different cell so that no two rooks still attack each other? A rook can move into any cell in its row or column if no other rook stands on its path.
The first line contains a single integer
The first line of each testcase contains two integers
The
No two rooks occupy the same cell. No two rooks attack each other.
For each testcase, print "YES" if it's possible to move exactly one rook into a different cell so that no two rooks still attack each other. Otherwise, print "NO".
22 21 22 13 12 2
NO
YES
In the first testcase, the rooks are in the opposite corners of a
In the second testcase, there's a single rook in a middle of a
- Get link
- X
- Other Apps
Comments
Post a Comment