Submission #984699

#TimeUsernameProblemLanguageResultExecution timeMemory
984699huutuanCircle selection (APIO18_circle_selection)C++14
100 / 100
1925 ms55192 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N=3e5+10; int n; pair<int, int> a[N]; int b[N], del[N]; map<pair<int, int>, vector<int>> mp; bool check(int i, int j){ return ((a[i].first-a[j].first)*(a[i].first-a[j].first)+(a[i].second-a[j].second)*(a[i].second-a[j].second))<=(b[i]+b[j])*(b[i]+b[j]); } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int x=0; cin >> n; for (int i=1; i<=n; ++i){ cin >> a[i].first >> a[i].second >> b[i]; a[i].first+=1e9; a[i].second+=1e9; x=max(x, b[i]); } vector<int> v(n); iota(v.begin(), v.end(), 1); sort(v.begin(), v.end(), [&](int k, int l){ return make_pair(b[k], -k)>make_pair(b[l], -l); }); auto build=[&](){ mp.clear(); for (int i=1; i<=n; ++i) if (!del[i]){ mp[{a[i].first/x, a[i].second/x}].push_back(i); } }; build(); for (int i:v){ if (del[i]) continue; if (b[i]<=x/2){ x/=2; build(); } for (int j=a[i].first/x-2; j<=a[i].first/x+2; ++j){ for (int k=a[i].second/x-2; k<=a[i].second/x+2; ++k){ if (!mp.count({j, k})) continue; for (int l:mp[{j, k}]) if (!del[l] && check(i, l)) del[l]=i; } } } for (int i=1; i<=n; ++i) cout << del[i] << " \n"[i==n]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...