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

7402번 - Farmer Bill’s Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB38101029.412%

문제

It is rumored that the planet Earth is often visited by Unidentified Flying Objects (UFOs). Sometimes UFOs land and leave burned out regions. Observations show that these regions have the form of circles.

Recently farmer Bill has found such circles on his nice rectangular wheat field. Bill likes all mysterious things very much, so he has decided to keep these circles on the field. However, although being an ufolog, first of all Bill is the farmer, so he needs to harvest his wheat. Therefore he has decided to keep some regions containing circles intact, and harvest the rest of the field.

All regions that Bill keeps unharvested must be rectangles that neither touch nor overlap each other. The sides of the rectangles must be parallel to the sides of the field. All circles left by UFOs must be inside these regions. The total area of the regions must be minimal possible, so that Bill could harvest the maximal possible part of his field.

Now Bill wants to know the total area of the field that he will be able to harvest. Help him!

입력

The first line of the input file contains two integer numbers $x$ and $y$ --- the dimensions of Bill's field (1ドル \le x, y \le 1000$). Let Bill's field be positioned on the plane in such a way that its corners are located in points with coordinates $(0, 0),ドル $(x, 0),ドル $(x, y)$ and $(0, y)$.

The second line of the input file contains $N$ --- the number of circles left by UFOs on Bill's field (0ドル \le N \le 100$). Next $N$ lines describe circles: each line contains three positive integer numbers $x_i,ドル $y_i$ and $r_i$ --- coordinates of the center and radius of the circle. Circles may touch, overlap or contain each other. All circles are completely located within the field bounds.

출력

Output a single integer number --- the area of the part of the field that Bill will be able to harvest.

제한

예제 입력 1

10 8
2
4 4 2
6 4 1

예제 출력 1

60

예제 입력 2

10 8
2
3 3 1
1 1 1

예제 출력 2

64

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2003 F번

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

출처

대학교 대회

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

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