# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
571625 | 2022-06-02T12:26:24 Z | Cross_Ratio | 원 고르기 (APIO18_circle_selection) | C++14 | 743 ms | 61096 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]; /*for(i=0;i<N;i++) { X[i] = rand() % 100; R[i] = rand() % 10; Y[i] = 0; }*/ 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->first <= 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->first <= 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 713 ms | 59980 KB | Output is correct |
2 | Correct | 725 ms | 61092 KB | Output is correct |
3 | Correct | 706 ms | 60768 KB | Output is correct |
4 | Correct | 713 ms | 61096 KB | Output is correct |
5 | Correct | 652 ms | 58764 KB | Output is correct |
6 | Correct | 743 ms | 58856 KB | Output is correct |
7 | Correct | 657 ms | 58984 KB | Output is correct |
8 | Correct | 661 ms | 58880 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 548 ms | 59600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |