Submission #1075389

#TimeUsernameProblemLanguageResultExecution timeMemory
1075389HappyCapybaraCircle selection (APIO18_circle_selection)C++17
19 / 100
550 ms62640 KiB
#include<bits/stdc++.h> using namespace std; double eps = pow(10, -9); double dist(int ax, int ay, int bx, int by){ return sqrt(pow(ax-bx, 2)+pow(ay-by, 2)); } int main(){ int n; cin >> n; vector<vector<int>> v(n); vector<pair<int,int>> ep; for (int i=0; i<n; i++){ int x, y, r; cin >> x >> y >> r; v[i] = {-r, i, x, y}; } sort(v.begin(), v.end()); for (int i=0; i<n; i++){ ep.push_back({v[i][2]+v[i][0], i}); ep.push_back({v[i][2]-v[i][0], i}); } sort(ep.begin(), ep.end()); vector<vector<int>> fts(n); for (int i=0; i<2*n; i++){ //cout << ep[i].first << " " << ep[i].second << "\n"; fts[ep[i].second].push_back(i); } set<int> todo; for (int i=0; i<n; i++) todo.insert(i); vector<int> done(n, 0); while (!todo.empty()){ int cur = *todo.begin(); if (n <= 5000){ for (int i=0; i<n; i++){ if (!done[v[i][1]] && dist(v[cur][2], v[cur][3], v[i][2], v[i][3]) < eps+(double) (0-(v[cur][0]+v[i][0]))){ done[v[i][1]] = v[cur][1]+1; todo.erase(i); } } } else { //cout << cur << "\n"; int l = fts[cur][0], r = fts[cur][1]; while (l > 0 && ep[l-1].first == ep[l].first) l--; while (r < 2*n-1 && ep[r+1].first == ep[r].first) r++; //cout << l << " " << r << "\n"; for (int i=l; i<=r; i++){ if (!done[ep[i].second]){ done[ep[i].second] = v[cur][1]+1; todo.erase(ep[i].second); } } } } if (n <= 5000) for (int i=0; i<n; i++) cout << done[i] << "\n"; else { vector<int> w(n); for (int i=0; i<n; i++) w[v[i][1]] = i; for (int i=0; i<n; i++) cout << done[w[i]] << "\n"; } }
#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...