Board Covering
Time limit1sMemory limit128 MB
Given an odd n by n board with three unit squares removed, decide whether the rest tiles perfectly with dominoes.
- Level
Medium6 of 10
- Topics
- Math, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
You are given a board of unit squares, where is an odd integer with . The squares are numbered consecutively row by row: the squares in the first row (left to right) get numbers to , the second row gets to , and so on, down to the bottom-right square, which is numbered .
Three of the squares are cut out of the board. We then try to cover the remaining squares with dominoes. Each domino is a tile that covers exactly two squares sharing an edge. A valid covering uses exactly dominoes so that every remaining square is covered by exactly one domino and no domino covers a cut-out square.
Determine whether such a covering of the board (with the three squares removed) is possible.
Input
A single line with four integers separated by single spaces: the board size , followed by the numbers of the three cut-out squares. The three numbers are distinct and each lies between and . The input is always well formed, so your program does not need to validate it.
Output
Print YES if the board with the three squares removed can be completely covered by dominoes under the rules above, otherwise print NO.