# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
571596 | 2022-06-02T11:39:16 Z | Cross_Ratio | Circle selection (APIO18_circle_selection) | C++14 | 694 ms | 56736 KB |
#include <bits/stdc++.h> #define int long long using namespace std; typedef pair<int,int> P; int X[300005]; int Y[300005]; int R[300005]; int ans[300005]; bool used[300005]; signed main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int N; cin >> N; int i, j; for(i=0;i<N;i++) cin >> X[i] >> Y[i] >> R[i]; priority_queue<P> PQ; set<P> S1, S2; for(i=0;i<N;i++) { S1.insert(P(X[i]+R[i],i)); S2.insert(P(X[i]-R[i],i)); PQ.push(P(R[i],-i)); ans[i] = -1; } while(true) { int id = -1; while(!PQ.empty()) { P k = PQ.top(); PQ.pop(); if(!used[-k.second]) { id = -k.second; break; } } if(id==-1) break; auto it1 = S1.lower_bound(P(X[id]-R[id],0)); while(it1 != S1.end()&&it1->second <= X[id] + R[id]) { ans[it1->second] = (ans[it1->second]==-1?id : ans[it1->second]); used[it1->second] = true; auto it2 = it1; it1++; S1.erase(it2); } it1 = S2.lower_bound(P(X[id]-R[id],0)); while(it1 != S2.end()&&it1->second <= X[id] + R[id]) { ans[it1->second] = (ans[it1->second]==-1?id : ans[it1->second]); used[it1->second] = true; auto it2 = it1; it1++; S2.erase(it2); } } for(i=0;i<N;i++) cout << ans[i]+1 << ' '; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 328 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 665 ms | 56736 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 694 ms | 55184 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 328 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 328 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |