Logo
(追記) (追記ここまで)

16421번 - Rectangles 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB131856668.750%

문제

You are working on a new graphics system, which has added a new feature. Whenever you draw a figure, all the pixels in that figure flip from white to black, or from black to white. This image is what happens when three overlapping rectangles are drawn on a white field:

Starting with a white field, given a series of axis-aligned rectangles, how many pixels end up black?

입력

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs.

Each test case will begin with a line with a single integer n (1 ≤ n ≤ 100,000) indicating the number of rectangles.

Each of the next n lines will have four space-separated integers x1, y1, x2 and y2 (0 ≤ x1 < x2 ≤ 109, 0 ≤ y1 < y2 ≤ 109) which represent opposite corners of a rectangle. The rectangle consists of all pixels (x,y) such that x1 ≤ x < x2 and y1 ≤ y < y2, so the area of the rectangle is (x2 - x1) × (y2 - y1) pixels.

출력

Output a single integer, which is the number of pixels that are black after all of the rectangles are drawn on a white field.

제한

예제 입력 1

2
0 0 4 4
1 1 3 3

예제 출력 1

12

예제 입력 2

4
0 0 10 10
1 1 11 11
2 2 12 12
3 3 13 13

예제 출력 2

72

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2018 Southeast USA Regional Programming Contest > Division 1 I번

ICPC > Regionals > North America > Southeast USA Regional > 2018 Southeast USA Regional Programming Contest > Division 2 F번

ICPC > Regionals > North America > Pacific Northwest Regional > 2018 Pacific Northwest Region Programming Contest > Division 1 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /