300759: CF144B. Meeting

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Meeting

题意翻译

超级超级秘密军事小组的超级超级秘密会议发生在一个超级超级秘密的地方。引入笛卡尔坐标系,得到一个无限平面。会议桌被表示为一个矩形,其边平行于坐标轴,顶点位于平面的整数点上。在每个属于桌子周边的整数点上,都有一张椅子,一般坐在上面。 平面上的一些点装有散热器,以防将军们在冬天被冻死。每个散热器用数字$r_i$表示散热器可以加热的区域的半径。也就是说,如果某个将军与给定散热器之间的距离小于或等于 $r_i$ ,就会比一般感觉舒适和温暖。这里距离被定义为欧几里德距离。 每个位于散热器加热区域之外的将军都可能生病。因此,你应该给他带一条暖和的毯子。你的任务是数一数你应该带多少温暖的毯子去超级超级秘密之地。 已经舒适的将军们不需要毛毯。此外,即使将军位于加热区域的几个散热器,他们永远不会过热。散热器可以位于平面上的任何整数点上,甚至在矩形内(桌子下面)或在周长上(直接在一些将军的下面)。即使在这种情况下,它们的半径也不会改变。

题目描述

The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose vertexes are located at the integer points of the plane. At each integer point which belongs to the table perimeter there is a chair in which a general sits. Some points on the plane contain radiators for the generals not to freeze in winter. Each radiator is characterized by the number $ r_{i} $ — the radius of the area this radiator can heat. That is, if the distance between some general and the given radiator is less than or equal to $ r_{i} $ , than the general feels comfortable and warm. Here distance is defined as Euclidean distance, so the distance between points $ (x_{1},y_{1}) $ and $ (x_{2},y_{2}) $ is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF144B/db1ba0d5909a3b47109b2e5f65fe13400ae1bd9a.png) Each general who is located outside the radiators' heating area can get sick. Thus, you should bring him a warm blanket. Your task is to count the number of warm blankets you should bring to the Super Duper Secret Place. The generals who are already comfortable do not need a blanket. Also the generals never overheat, ever if they are located in the heating area of several radiators. The radiators can be located at any integer points on the plane, even inside the rectangle (under the table) or on the perimeter (directly under some general). Even in this case their radius does not change.

输入输出格式

输入格式


The first input line contains coordinates of two opposite table corners $ x_{a} $ , $ y_{a} $ , $ x_{b} $ , $ y_{b} $ ( $ x_{a}≠x_{b},y_{a}≠y_{b}) $ . The second line contains integer $ n $ — the number of radiators ( $ 1<=n<=10^{3} $ ). Then $ n $ lines contain the heaters' coordinates as " $ x_{i} $ $ y_{i} $ $ r_{i} $ ", the numbers are separated by spaces. All input data numbers are integers. The absolute value of all coordinates does not exceed $ 1000 $ , $ 1<=r_{i}<=1000 $ . Several radiators can be located at the same point.

输出格式


Print the only number — the number of blankets you should bring.

输入输出样例

输入样例 #1

2 5 4 2
3
3 1 2
5 3 1
1 3 2

输出样例 #1

4

输入样例 #2

5 2 6 3
2
6 2 2
6 5 3

输出样例 #2

0

说明

In the first sample the generals are sitting at points: $ (2,2) $ , $ (2,3) $ , $ (2,4) $ , $ (2,5) $ , $ (3,2) $ , $ (3,5) $ , $ (4,2) $ , $ (4,3) $ , $ (4,4) $ , $ (4,5) $ . Among them, 4 generals are located outside the heating range. They are the generals at points: $ (2,5) $ , $ (3,5) $ , $ (4,4) $ , $ (4,5) $ . In the second sample the generals are sitting at points: $ (5,2) $ , $ (5,3) $ , $ (6,2) $ , $ (6,3) $ . All of them are located inside the heating range.

Input

题意翻译

超级超级秘密军事小组的超级超级秘密会议发生在一个超级超级秘密的地方。引入笛卡尔坐标系,得到一个无限平面。会议桌被表示为一个矩形,其边平行于坐标轴,顶点位于平面的整数点上。在每个属于桌子周边的整数点上,都有一张椅子,一般坐在上面。 平面上的一些点装有散热器,以防将军们在冬天被冻死。每个散热器用数字$r_i$表示散热器可以加热的区域的半径。也就是说,如果某个将军与给定散热器之间的距离小于或等于 $r_i$ ,就会比一般感觉舒适和温暖。这里距离被定义为欧几里德距离。 每个位于散热器加热区域之外的将军都可能生病。因此,你应该给他带一条暖和的毯子。你的任务是数一数你应该带多少温暖的毯子去超级超级秘密之地。 已经舒适的将军们不需要毛毯。此外,即使将军位于加热区域的几个散热器,他们永远不会过热。散热器可以位于平面上的任何整数点上,甚至在矩形内(桌子下面)或在周长上(直接在一些将军的下面)。即使在这种情况下,它们的半径也不会改变。

加入题单

算法标签: