#K52762. Non-Attacking Rooks Placement
Non-Attacking Rooks Placement
Non-Attacking Rooks Placement
You are given an n × m chessboard and an integer k. The task is to determine whether it is possible to place k rooks on the board such that no two rooks can attack each other.
Recall that a rook can move and attack any piece along the same row or column. Hence, two rooks will not attack each other if and only if they are placed in different rows and different columns. This placement is possible if and only if:
$$k \leq \min(n, m)$$
If the above inequality holds, output YES
; otherwise, output NO
.
inputFormat
The input is given via standard input and consists of three space-separated integers:
- n: the number of rows in the grid.
- m: the number of columns in the grid.
- k: the number of rooks to be placed.
It is guaranteed that the input values are valid integers.
outputFormat
Output a single line to the standard output. Print YES
if it is possible to place the k rooks such that none attack each other, otherwise print NO
.
3 3 2
YES