POJ 1899 Farmer Bill's Problem

 

Farmer Bill's Problem
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 2159 Accepted: 514

Description

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!

Input

The first line of the input contains two integer numbers x and y -- the dimensions of Bill's field (1 <= x, y <= 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 case contains N -- the number of circles left by UFOs on Bill's field (0 <= N <= 100). Next N lines describe circles: each line contains three positive integer numbers xi, yi and ri -- 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

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

Sample Input

10 8
2
3 3 1
1 1 1

Sample Output

64

Source

 

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值