Submission #75644

#TimeUsernameProblemLanguageResultExecution timeMemory
75644tmwilliamlin168Circle selection (APIO18_circle_selection)C++14
19 / 100
3049 ms154688 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxN=3e5; int n, p[mxN], a[mxN]; ll x[mxN], y[mxN], r[mxN]; unordered_map<ll, vector<int>> mp; void rs(int k) { mp.clear(); for(int i=0; i<n; ++i) if(a[i]==-1) mp[x[i]>>k<<32|y[i]>>k].push_back(i); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=0; i<n; ++i) { cin >> x[i] >> y[i] >> r[i]; p[i]=i; } sort(p, p+n, [&](const int &a, const int &b) { return r[a]==r[b]?a<b:r[a]>r[b]; }); memset(a, -1, 4*n); for(int i=-1, k=30; i+1<n; --i, --k) { rs(k); while(++i<n&&r[p[i]]>=1<<(k-1)) { // cout << p[i] << endl; if(a[p[i]]!=-1) continue; // cout << p[i] << endl; for(ll b=(x[p[i]]>>k)-2; b<=(x[p[i]]>>k)+2; ++b) { for(ll c=(y[p[i]]>>k)-2; c<=(y[p[i]]>>k)+2; ++c) { int ns=0; //vector &v; for(int j=0; j<mp[b<<32|c].size(); ++j) { ll dx=x[p[i]]-x[mp[b<<32|c][j]], dy=y[p[i]]-y[mp[b<<32|c][j]], rs=r[p[i]]+r[mp[b<<32|c][j]]; if(dx*dx+dy*dy<=rs*rs) a[mp[b<<32|c][j]]=p[i]; else mp[b<<32|c][ns++]=mp[b<<32|c][j]; } mp[b<<32|c].resize(ns); } } } } for(int i=0; i<n; ++i) cout << a[i]+1 << " "; }

Compilation message (stderr)

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:42:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for(int j=0; j<mp[b<<32|c].size(); ++j) {
                   ~^~~~~~~~~~~~~~~~~~~
#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...