#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++) {
~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
9728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
601 ms |
25312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
9728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3006 ms |
22440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
9728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
9728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |