Submission #968175

#TimeUsernameProblemLanguageResultExecution timeMemory
968175socpiteCircle selection (APIO18_circle_selection)C++14
23 / 100
1293 ms48976 KiB
#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 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...