답안 #980779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980779 2024-05-12T11:38:51 Z Unforgettablepl 원 고르기 (APIO18_circle_selection) C++17
0 / 100
3 ms 860 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

vector<int> adj[5001];
pair<int,pair<int,int>> circles[5001];
int ans[5001];

bool check(int a,int b){
    return (circles[a].first+circles[b].first)*(circles[a].first+circles[b].first)>=(circles[a].second.first-circles[b].second.first)*(circles[a].second.first-circles[b].second.first)+(circles[a].second.second-circles[b].second.second)*(circles[a].second.second-circles[b].second.second);
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)cin>>circles[i].second.first>>circles[i].second.second>>circles[i].first;
    set<pair<int,int>> circle;
    set<pair<int,int>> activepos;
    for(int i=1;i<=n;i++){
        circle.insert({circles[i].first,-i});
        activepos.insert({circles[i].second.first-circles[i].first,i});
        activepos.insert({circles[i].second.first+circles[i].first,i});
    }
    auto remove = [&](int x,int p){
        if(circle.count({circles[x].first,-x})) {
            circle.erase({circles[x].first, -x});
            ans[x] = p;
        }
    };
    while(!circle.empty()){
        auto curr = *--circle.end();curr.second=-curr.second;
        auto iter1 = activepos.lower_bound({circles[curr.second].second.first-circles[curr.second].first,0});
        auto iter2 = activepos.lower_bound({circles[curr.second].second.first+circles[curr.second].first+1,0});
        while(iter1!=iter2){
            remove(iter1->second,curr.second);
            iter1=activepos.erase(iter1);
        }
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -