#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 3e5;
int n;
vector<pair<int,pair<int,int>>> circles(MAX);
vector<int> old,cur;
vector<int> elim(MAX);
int dist(pair<int,int> p1, pair<int,int> p2) {
return (p2.first-p1.first)*(p2.first-p1.first) + (p2.second-p1.second)*(p2.second-p1.second);
}
bool intsct(pair<int,pair<int,int>> c1, pair<int,pair<int,int>> c2) {
return dist(c1.second,c2.second) <= (c1.first+c2.first)*(c1.first+c2.first);
}
main() {
// cin.tie(0);
// ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) {
int x,y,r; cin >> x >> y >> r;
circles[i] = make_pair(r,make_pair(x,y));
cur.push_back(i);
}
while (cur.size() > 0) {
old = cur; cur.clear();
sort(old.begin(),old.end(),[](int i, int j) {return circles[i].first > circles[j].first || (circles[i].first == circles[j].first && i < j);});
// cout << old[0]+1 << ": ";
for (int i = 0; i < old.size(); i++) {
if (!intsct(circles[old[i]],circles[old[0]])) {
cur.push_back(old[i]);
}
else {
elim[old[i]] = old[0];
//cout << old[i]+1 << " ";
}
}
// cout << "\n";
}
for (int i = 0; i < n; i++) {
cout << elim[i]+1 << " ";
}
return 0;
}
Compilation message
circle_selection.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:39:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < old.size(); i++) {
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
8 ms |
9728 KB |
Output is correct |
3 |
Correct |
9 ms |
9728 KB |
Output is correct |
4 |
Correct |
9 ms |
9728 KB |
Output is correct |
5 |
Correct |
8 ms |
9728 KB |
Output is correct |
6 |
Correct |
9 ms |
9728 KB |
Output is correct |
7 |
Correct |
9 ms |
9728 KB |
Output is correct |
8 |
Correct |
9 ms |
9728 KB |
Output is correct |
9 |
Correct |
9 ms |
9728 KB |
Output is correct |
10 |
Correct |
9 ms |
9728 KB |
Output is correct |
11 |
Correct |
11 ms |
9720 KB |
Output is correct |
12 |
Correct |
10 ms |
9728 KB |
Output is correct |
13 |
Correct |
11 ms |
9728 KB |
Output is correct |
14 |
Correct |
11 ms |
9728 KB |
Output is correct |
15 |
Correct |
9 ms |
9728 KB |
Output is correct |
16 |
Correct |
10 ms |
9728 KB |
Output is correct |
17 |
Correct |
10 ms |
9728 KB |
Output is correct |
18 |
Correct |
10 ms |
9728 KB |
Output is correct |
19 |
Correct |
16 ms |
9984 KB |
Output is correct |
20 |
Correct |
23 ms |
9984 KB |
Output is correct |
21 |
Correct |
21 ms |
9984 KB |
Output is correct |
22 |
Correct |
402 ms |
9984 KB |
Output is correct |
23 |
Correct |
407 ms |
10104 KB |
Output is correct |
24 |
Correct |
465 ms |
10104 KB |
Output is correct |
25 |
Correct |
390 ms |
9976 KB |
Output is correct |
26 |
Correct |
415 ms |
10104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
468 ms |
16692 KB |
Output is correct |
2 |
Correct |
496 ms |
23232 KB |
Output is correct |
3 |
Correct |
449 ms |
23008 KB |
Output is correct |
4 |
Correct |
447 ms |
23396 KB |
Output is correct |
5 |
Execution timed out |
3078 ms |
19332 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9728 KB |
Output is correct |
2 |
Execution timed out |
3017 ms |
14216 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3023 ms |
14648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
8 ms |
9728 KB |
Output is correct |
3 |
Correct |
9 ms |
9728 KB |
Output is correct |
4 |
Correct |
9 ms |
9728 KB |
Output is correct |
5 |
Correct |
8 ms |
9728 KB |
Output is correct |
6 |
Correct |
9 ms |
9728 KB |
Output is correct |
7 |
Correct |
9 ms |
9728 KB |
Output is correct |
8 |
Correct |
9 ms |
9728 KB |
Output is correct |
9 |
Correct |
9 ms |
9728 KB |
Output is correct |
10 |
Correct |
9 ms |
9728 KB |
Output is correct |
11 |
Correct |
11 ms |
9720 KB |
Output is correct |
12 |
Correct |
10 ms |
9728 KB |
Output is correct |
13 |
Correct |
11 ms |
9728 KB |
Output is correct |
14 |
Correct |
11 ms |
9728 KB |
Output is correct |
15 |
Correct |
9 ms |
9728 KB |
Output is correct |
16 |
Correct |
10 ms |
9728 KB |
Output is correct |
17 |
Correct |
10 ms |
9728 KB |
Output is correct |
18 |
Correct |
10 ms |
9728 KB |
Output is correct |
19 |
Correct |
16 ms |
9984 KB |
Output is correct |
20 |
Correct |
23 ms |
9984 KB |
Output is correct |
21 |
Correct |
21 ms |
9984 KB |
Output is correct |
22 |
Correct |
402 ms |
9984 KB |
Output is correct |
23 |
Correct |
407 ms |
10104 KB |
Output is correct |
24 |
Correct |
465 ms |
10104 KB |
Output is correct |
25 |
Correct |
390 ms |
9976 KB |
Output is correct |
26 |
Correct |
415 ms |
10104 KB |
Output is correct |
27 |
Correct |
25 ms |
10240 KB |
Output is correct |
28 |
Correct |
33 ms |
10232 KB |
Output is correct |
29 |
Correct |
27 ms |
10240 KB |
Output is correct |
30 |
Correct |
1911 ms |
10232 KB |
Output is correct |
31 |
Correct |
1939 ms |
10292 KB |
Output is correct |
32 |
Correct |
1975 ms |
10232 KB |
Output is correct |
33 |
Correct |
219 ms |
15084 KB |
Output is correct |
34 |
Correct |
199 ms |
15084 KB |
Output is correct |
35 |
Correct |
205 ms |
15084 KB |
Output is correct |
36 |
Execution timed out |
3037 ms |
14060 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
8 ms |
9728 KB |
Output is correct |
3 |
Correct |
9 ms |
9728 KB |
Output is correct |
4 |
Correct |
9 ms |
9728 KB |
Output is correct |
5 |
Correct |
8 ms |
9728 KB |
Output is correct |
6 |
Correct |
9 ms |
9728 KB |
Output is correct |
7 |
Correct |
9 ms |
9728 KB |
Output is correct |
8 |
Correct |
9 ms |
9728 KB |
Output is correct |
9 |
Correct |
9 ms |
9728 KB |
Output is correct |
10 |
Correct |
9 ms |
9728 KB |
Output is correct |
11 |
Correct |
11 ms |
9720 KB |
Output is correct |
12 |
Correct |
10 ms |
9728 KB |
Output is correct |
13 |
Correct |
11 ms |
9728 KB |
Output is correct |
14 |
Correct |
11 ms |
9728 KB |
Output is correct |
15 |
Correct |
9 ms |
9728 KB |
Output is correct |
16 |
Correct |
10 ms |
9728 KB |
Output is correct |
17 |
Correct |
10 ms |
9728 KB |
Output is correct |
18 |
Correct |
10 ms |
9728 KB |
Output is correct |
19 |
Correct |
16 ms |
9984 KB |
Output is correct |
20 |
Correct |
23 ms |
9984 KB |
Output is correct |
21 |
Correct |
21 ms |
9984 KB |
Output is correct |
22 |
Correct |
402 ms |
9984 KB |
Output is correct |
23 |
Correct |
407 ms |
10104 KB |
Output is correct |
24 |
Correct |
465 ms |
10104 KB |
Output is correct |
25 |
Correct |
390 ms |
9976 KB |
Output is correct |
26 |
Correct |
415 ms |
10104 KB |
Output is correct |
27 |
Correct |
468 ms |
16692 KB |
Output is correct |
28 |
Correct |
496 ms |
23232 KB |
Output is correct |
29 |
Correct |
449 ms |
23008 KB |
Output is correct |
30 |
Correct |
447 ms |
23396 KB |
Output is correct |
31 |
Execution timed out |
3078 ms |
19332 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |