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

Paint by Rectangles

Diamond II 다이아몬드 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

After her previous
artwork
was met with critical acclaim, Bessie was offered a job designing
painting sets. She designs these paintings by choosing \(1\le N\le 10^5\)
axis-aligned rectangles in the plane such that no two edges are collinear. The
boundaries of these rectangles define the boundaries of the painting's colored
regions.

Still being an avant-garde artist, Bessie decides that the painting should
resemble a Holstein cow. More specifically, each region formed by the rectangles
is colored either black or white, no two adjacent regions have the same color,
and the region outside of all the rectangles is colored white.

After choosing the rectangles, Bessie would like you to output one of two things
based on a parameter \(T\):

  • If \(T=1\), output the total number of regions.
  • If \(T=2\), output the number of white regions followed by the number of black regions.

*Note: the time limit for this problem is 4s, twice the default.*

Problem credits: Andi Qu

제약

SCORING

  1. Test cases 3-4 satisfy \(N\le 10^3\).
  2. In test cases 5-7, no two rectangle boundaries intersect.
  3. In test cases 8-10, \(T=1\) and the boundaries of all rectangles are connected.
  4. In test cases 11-13, \(T=2\) and the boundaries of all rectangles are connected.
  5. In test cases 14-18, \(T=1\).
  6. In test cases 19-23, \(T=2\).

Problem credits: Andi Qu

입력 형식

The first line contains \(N\) and \(T\).

The next \(N\) lines each contain the description of a rectangle in the form
\((x_1,y_1), (x_2,y_2)\) where \(1\le x_1 and \(1\le y_1.
\((x_1, y_1)\) and \((x_2, y_2)\) are the bottom left and top right corners of the
rectangle respectively.

It is guaranteed that all the \(x_i\) form a permutation of \(1\ldots 2N\), and the
same holds for all the \(y_i\).

출력 형식

A single integer if \(T=1\), otherwise two separated by spaces.

예제 1
입력
2 1
1 1 3 3
2 2 4 4
출력
4
설명

There are two white regions and two black regions, for a total of four regions.
The boundaries of all rectangles are connected, so this input would satisfy the
conditions of subtask 3.

예제 2
입력
5 2
1 5 3 6
5 4 7 9
4 1 8 3
9 8 10 10
2 2 6 7
출력
4 5
설명

The boundary of the rectangle in the upper-right is not connected to the rest of
the boundaries, so this input would not satisfy the conditions of subtask 4.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2021-2022 > February > Platinum

태그

평가 및 의견

Paint by Rectangles

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

Log in to rate problems.

개별 의견

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

풀이 제출

Paint by Rectangles

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