Submission #1070879

#TimeUsernameProblemLanguageResultExecution timeMemory
1070879wfe2017Circle selection (APIO18_circle_selection)C++14
0 / 100
55 ms2652 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; const char nl = '\n'; void fastIO() { ios::sync_with_stdio(false); cin.tie(0); } int main() { fastIO(); int N; cin>>N; vector<ii> cr(N); for (int i = 0; i < N; i++) { int x, y, r; cin>>x>>y>>r; cr[i] = {x, r}; } if(N > 100000) return 0; multiset<ii> lpos; // {lp, id} multiset<ii> rpos; // {rp, id} multiset<ii> have; // {r, -id]} for (int i = 0; i < N; i++) { int x = cr[i].fi; int r = cr[i].se; lpos.insert({x + r, i}); rpos.insert({x - r, i}); have.insert({r, -i}); } vi par(N, -1); int rem = N; while (rem != 0) { auto it = --have.end(); int id = -(*it).se; // id of current circle int x = cr[id].fi; int r = cr[id].se; int lp = x - r; int rp = x + r; // cout<<"lp, rp: "<<lp<<" "<<rp<<endl; // find all circles with lp[i], rp[i] in [lp, rp] set<int> tr; // id of circles to remove auto it2 = lpos.lower_bound({lp, -1}); while ((it2 != lpos.end()) && ((*it2).fi <= rp)) { tr.insert((*it2).se); it2++; } auto it3 = rpos.lower_bound({lp, -1}); while ((it3 != rpos.end()) && ((*it3).fi <= rp)) { tr.insert((*it3).se); it3++; } for (int x : tr) { par[x] = id; rem--; lpos.erase({cr[x].fi - cr[x].se, x}); rpos.erase({cr[x].fi + cr[x].se, x}); have.erase({cr[x].se, x}); } // cout<<id<<": "<<rem<<endl; } // cout<<"ANSWER: "; for (int x : par) cout<<(x + 1)<<" "; cout<<endl; }
#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...