#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
bool Q = true;
struct circle{
int x, y, r, id;
bool operator<(const circle& a)const{
if(Q) return r > a.r || (r == a.r && id < a.id);
else return x < a.x || (x == a.x && id < a.id);
}
};
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
set<circle> X;
set<circle> data;
int n;
cin >> n;
vector<int> ans(n);
for(int i = 0; i < n; i++){
int x, y, r;
cin >> x >> y >> r;
Q = false;
X.insert({x, y, r, i});
Q = true;
data.insert({x, y, r, i});
}
while(!data.empty()){
Q = true;
circle c = *data.begin();
data.erase(data.begin());
Q = false;
auto itr = X.find(c);
auto i = next(itr);
while((i = next(itr)) != X.end() && i->x - itr->x <= i->r + itr->r){
circle t = *i;
ans[t.id] = itr->id;
X.erase(i);
Q = true;
data.erase(t);
Q = false;
}
i = prev(itr);
while(itr != X.begin() && itr->x - i->x <= i->r + itr->r){
circle t = *i;
ans[t.id] = itr->id;
X.erase(i);
Q = true;
data.erase(t);
Q = false;
i = prev(itr);
}
circle t = *itr;
ans[t.id] = itr->id;
X.erase(itr);
Q = true;
}
for(int i = 0; i < n; i++){
cout << ans[i] + 1 << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1072 ms |
58592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
833 ms |
59328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |