-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1004.cpp
More file actions
71 lines (55 loc) · 1.1 KB
/
Copy path1004.cpp
File metadata and controls
71 lines (55 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <vector>
using namespace std;
struct Planet {
int cx, cy, r;
};
int T;
int n;
int x1, y1, x2, y2;
vector<Planet> v;
void init() {
n=0;
x1=0; y1=0; x2=0; y2=0;
v.clear();
}
void input() {
cin >> x1 >> y1 >> x2 >> y2;
cin >> n;
for (int i=0; i<n; i++) {
int cx, cy, r;
cin >> cx >> cy >> r;
Planet p = {cx, cy, r};
v.push_back(p);
}
}
bool checkInside(int x, int y, int cx, int cy, int r) {
int dx = x-cx;
int dy = y-cy;
if(dx*dx + dy*dy <= r*r) {
return true;
}
return false;
}
void solve() {
int cnt = 0;
for (int i=0; i<n; i++) {
if (checkInside(x1,y1,v[i].cx,v[i].cy,v[i].r) && !checkInside(x2,y2,v[i].cx,v[i].cy,v[i].r)) {
cnt++;
} else if(!checkInside(x1,y1,v[i].cx,v[i].cy,v[i].r) && checkInside(x2,y2,v[i].cx,v[i].cy,v[i].r)) {
cnt++;
}
}
cout << cnt << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> T;
while(T--) {
init();
input();
solve();
}
return 0;
}