RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0672

Forklift Certified

Platinum II 플래티넘 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John is training to become forklift certified! As part of his training,
he needs to clear \(N\) (\(1 \le N \le 10^5\)) boxes, conveniently labeled \(1\)
through \(N\), from an old warehouse.

The boxes can be modeled as axis-aligned rectangles in a 2-dimensional plane,
where the \(+x\)-direction is east and the \(+y\)-direction is north. Box \(i\) has
its southwest corner at \((x_{i1},y_{i1})\) and its northeast corner at
\((x_{i2},y_{i2})\). All coordinates are integers in the range \([1, 2N]\), and no
two corners from two different rectangles share the same \(x\) or \(y\) coordinate.
All boxes have a non-zero area, and no two boxes intersect.

Farmer John plans to remove the boxes one at a time out of the southwest
entrance of the warehouse. However, he can only remove a box if no part of any
other box lies both south and west of the box's northeast corner due to physical
limitations of the forklift.

An example with \(N=4\) is shown below. To remove box \(4\), there cannot be any
other boxes in the shaded region. Boxes \(2\) and \(3\) prevent box \(4\) from being
removed, but box \(1\) does not.

Help Farmer John decide how to remove all the boxes! Your code should operate in
two separate modes, defined by an integer flag \(M\):

  • Mode 1 (\(M = 1\)): Generate a permutation of \(1, \dots, N\) specifying a valid box removal order. If there are multiple valid orders, find any. It can be proven that such an order always exists.
  • Mode 2 (\(M = 2\)): For each \(k = 1, \dots, N\), output \(\texttt{1}\) if Farmer John can remove box \(k\) if boxes \(1, \dots, k - 1\) have already been removed, and \(\texttt{0}\) otherwise.

Problem credits: Austin Geng

제약

SCORING

  • Inputs 3-5: \(M = 1\), \(N\le 1000\).
  • Input 6: \(M = 2\), \(N \le 1000\).
  • Inputs 7-13: \(M = 1\), no additional constraints.
  • Inputs 14-16: \(M = 2\), no additional constraints.

Problem credits: Austin Geng

입력 형식

Each input consists of \(T\) (\(1 \le T \le 10\)) independent test cases. It is
guaranteed that the sum of all \(N\) within each input does not exceed
\(5 \cdot 10^5\).

The first line of input contains \(T\) and \(M\). (Note that \(M\) is the same for
each test case.) Each test case is then formatted as follows:

  • The first line contains a single integer \(N\).
  • Each of the next \(N\) lines contains four space-separated integers \(x_{i1}, y_{i1}, x_{i2}, y_{i2}\): the locations of the southwest and northeast corners of box \(i\).
출력 형식

For each test case:

  • If \(M = 1\), output a single line with \(N\) space-separated integers, where the \(j\)-th integer is the label of the \(j\)-th box to remove.
  • If \(M = 2\), output a single line with a binary string of \(N\) characters specifying the answer for each \(k = 1, \dots, N\).
예제 1
입력
2 1
4
1 6 2 8
6 2 7 3
3 1 4 7
5 4 8 5
3
1 5 3 6
4 1 5 2
2 3 6 4
출력
1 3 2 4
2 3 1
설명

The first test case corresponds to the \(N = 4\) example above. Box \(1\) is not
blocked by anything, box \(3\) is blocked by box \(1\), box \(2\) is blocked by box
\(3\), and box \(4\) is blocked by boxes \(2\) and \(3\).

예제 2
입력
2 2
4
1 6 2 8
6 2 7 3
3 1 4 7
5 4 8 5
3
1 5 3 6
4 1 5 2
2 3 6 4
출력
1011
011
설명

For the first test case, box \(2\) is blocked by box \(3\), so Farmer John cannot
remove it before removing box \(3\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > US Open > Platinum

태그

평가 및 의견

Forklift Certified

개요
출제자 난이도 Platinum II 플래티넘 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Forklift Certified

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8