This repository was archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1072.cpp
More file actions
65 lines (62 loc) · 1.94 KB
/
1072.cpp
File metadata and controls
65 lines (62 loc) · 1.94 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
#include <iostream>
#include <iomanip>
using namespace std;
class CircleSet {
friend istream &operator>>(istream &in, CircleSet &obj);
private:
struct Circle {
long long x, y, r;
Circle(long long _x = 0, long long _y = 0, long long _r = 0): x(_x), y(_y), r(_r) {}
};
int count;//集合中圆的数目
Circle *circles;//集合中所有圆
long long quad_ (long long a) { return a * a; }
public:
CircleSet(int n): count(n) {
circles = new Circle[n];
}
~CircleSet () { delete[] circles; }
long long operator[] (int i) { return circles[i].r; }
bool checkContaining (int p, int q) {
if (circles[p].r <= circles[q].r) return false;
return quad_(circles[p].x - circles[q].x) + quad_(circles[p].y - circles[q].y) < quad_(circles[p].r - circles[q].r);
}
int getCircleContainingQ (int q) {
int min = 19260817;
for (int i = 0; i < count; ++i) if (checkContaining(i, q)) min = min > circles[i].r ? circles[i].r : min;
return min;
}
};
istream &operator>>(istream &in, CircleSet &obj) {
for (int i = 0; i < obj.count; ++i) {
in >> obj.circles[i].x >> obj.circles[i].y >> obj.circles[i].r;
}
return in;
}
#ifndef ONLINE_JUDGE
int main() {
int n, m, type;
cin >> n >> m;
CircleSet set(n);
cin >> set; //输入集合中的所有圆
while (m--) {
int type, p, q;
cin >> type;
if (type == 1) {
//do nothing
} else if (type == 2) {
for (int i = 0; i < n; ++i) {
cout << set[i] << ' ';
}
cout << endl;
} else if (type == 3) {
cin >> p >> q;
cout << set.checkContaining(p, q) << endl;
} else if (type == 4) {
cin >> q;
cout << set.getCircleContainingQ(q) << endl;
}
}
return 0;
}
#endif