Submission #698791

#TimeUsernameProblemLanguageResultExecution timeMemory
698791vjudge1Circle selection (APIO18_circle_selection)C++17
0 / 100
189 ms13916 KiB
#include "bits/stdc++.h" #define ll long long using namespace std; const ll mod = 1000000007; signed main () { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("cowland.in","r",stdin); // freopen("cowland.out","w",stdout); int n; cin >> n; vector<pair<int, pair<int, int>>> v; int rr[n]; for(int i = 0; i < n; i++) { int x, y, r; cin >> x >> y >> r; rr[i] = r; v.push_back({x - r, {0, i}}); v.push_back({x + r, {1, i}}); } sort(v.begin(), v.end()); priority_queue<pair<int, int>> pq; int ans[n]; for(int i = 0; i < n; i++) ans[i] = -1; bool b[n] = {}; for(int i = 0; i < n * 2; i++) { if(v[i].second.first == 0) { if(!pq.empty()) ans[v[i].second.second] = pq.top().second + 1; pq.push({rr[v[i].second.second], v[i].second.second}); } else { b[v[i].second.second] = 1; while(!pq.empty() && (b[pq.top().second] || ans[pq.top().second])) b[pq.top().second] = 0, pq.pop(); } } for(int i = n * 2 - 1; i >= 0; i--) { if(v[i].second.first == 0) { if(!pq.empty()) ans[v[i].second.second] = pq.top().second + 1; pq.push({rr[v[i].second.second], v[i].second.second}); } else { b[v[i].second.second] = 1; while(!pq.empty() && (b[pq.top().second] || ans[pq.top().second])) b[pq.top().second] = 0, pq.pop(); } } for(int i = 0; i < n; i++) { if(ans[i] == -1) ans[i] = i; cout << ans[i] << " "; } 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...