import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
xa, ya, xb, yb = map(int, input().split())
xa, xb = min(xa, xb), max(xa, xb)
ya, yb = min(ya, yb), max(ya, yb)
n = int(input())
xyr = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
x, y = xa, ya
u = [xb - xa, yb - ya]
v = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for i in range(4):
dx, dy = v[i]
for _ in range(u[i % 2]):
f = 0
for x0, y0, r in xyr:
if pow(x0 - x, 2) + pow(y0 - y, 2) <= r * r:
f = 1
break
if not f:
ans += 1
x, y = x + dx, y + dy
print(ans)
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c, d;
vector<pair<int, int>>general;
cin >> a >> b >> c >> d;
int x1 = min(a,c), y1 = min(b,d), x2 = max(a,c), y2 = max(b,d);
while (1)
{
general.push_back(make_pair(x1,y1));
y1++;
if (y1 > y2)
break;
}
y1 = min(b, d);
while (1)
{
general.push_back(make_pair(x2, y1));
y1++;
if (y1 > y2)
break;
}
x1 = min(a, c), y1 = min(b, d), x2 = max(a, c), y2 = max(b, d);
for (int i = x1 + 1; i < x2; i++)
{
general.push_back(make_pair(i, y1));
general.push_back(make_pair(i, y2));
}
int n;
int x, y, r;
cin >> n;
vector<tuple<int, int, int>>radiator;
for (int i = 0;i<n;i++)
{
cin >> x >> y >> r;
radiator.push_back(make_tuple(x, y, r));
}
float distance = 0;
int result = 0;
int flag = 0;
for (auto i = 0; i < general.size(); i++)
{
for (int j = 0; j < radiator.size();j++)
{
distance = sqrt(pow(abs(general[i].first - get<0>(radiator[j])), 2) + pow(abs(general[i].second - get<1>(radiator[j])), 2));
if (distance <= get<2>(radiator[j]))
{
flag = 1;
break;
}
}
if (flag == 0)
result++;
flag = 0;
}
cout << result << endl;
}
1337B - Kana and Dragon Quest game | 137C - History |
1443C - The Delivery Dilemma | 6C - Alice Bob and Chocolate |
1077C - Good Array | 285B - Find Marble |
6A - Triangle | 1729A - Two Elevators |
1729B - Decode String | 1729C - Jumping on Tiles |
1729E - Guess the Cycle Size | 553B - Kyoya and Permutation |
1729D - Friends and the Restaurant | 1606C - Banknotes |
580C - Kefa and Park | 342A - Xenia and Divisors |
1033A - King Escape | 39D - Cubical Planet |
1453A - Cancel the Trains | 645A - Amity Assessment |
1144A - Diverse Strings | 1553B - Reverse String |
1073A - Diverse Substring | 630N - Forecast |
312B - Archer | 34D - Road Map |
630I - Parking Lot | 160B - Unlucky Ticket |
371B - Fox Dividing Cheese | 584B - Kolya and Tanya |