This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+5;
const int INF = 1e9;
pair<int, int> pt[maxn];
int R[maxn], removed[maxn];
int n;
bool check(int a, int b){
return 1LL*(pt[a].first - pt[b].first)*(pt[a].first - pt[b].first) + 1LL*(pt[a].second - pt[b].second)*(pt[a].second - pt[b].second) - 1LL*(R[a] + R[b])*(R[a] + R[b]) <= 0;
}
map<pair<int, int>, vector<int>> mp;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
vector<int> vec(n);
iota(vec.begin(), vec.end(), 1);
int mx = 0;
for(int i = 1; i <= n; i++){
cin >> pt[i].first >> pt[i].second >> R[i];
pt[i].first += INF;
pt[i].second += INF;
mx = max(mx, R[i]);
}
for(int i = 1; i <= n; i++){
mp[{pt[i].first/mx, pt[i].second/mx}].push_back(i);
}
for(int i = 1; i <= n; i++){
if(!removed[i])
for(int j = pt[i].first/mx - 2; j <= pt[i].first/mx + 2; j++){
for(int k = pt[i].second/mx - 2; k <= pt[i].second/mx + 2; k++){
if(mp.find(make_pair(j, k)) == mp.end())continue;
for(auto v: mp[{j, k}])if(!removed[v] && check(v, i))removed[v] = i;
}
}
cout << removed[i] << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |