#C1184. Grid Filling Feasibility
Grid Filling Feasibility
Grid Filling Feasibility
You are given a grid with n rows and m columns. The challenge is to determine whether it is possible to fill the grid by placing exactly one "1" in each row within a specified contiguous block of columns such that no column contains more than one "1".
For each test case, you are provided with four integers: n, m, l, and r. Here, l and r define the inclusive range of columns where the "1" must be placed in every row. The task is possible if and only if the number of available columns in the specified range satisfies
[ r - l + 1 \ge n ]
Otherwise, it is impossible to assign each row a distinct column within that range.
Your output should be "YES" if the grid can be filled according to the given conditions, or "NO" otherwise for each test case.
inputFormat
The first line contains an integer (T) denoting the number of test cases. Each test case is described on a single line containing four space-separated integers:
(n) (m) (l) (r)
where:
- (n) is the number of rows in the grid,
- (m) is the number of columns in the grid,
- (l) is the starting column index of the allowed range,
- (r) is the ending column index of the allowed range.
Note: Columns are 1-indexed.
outputFormat
For each test case, output a single line containing either "YES" if it is possible to fill the grid as required or "NO" if it is not.## sample
3
3 5 2 4
4 4 1 4
2 6 3 3
YES
YES
NO
</p>