Submission #698796

# Submission time Handle Problem Language Result Execution time Memory
698796 2023-02-14T10:03:23 Z vjudge1 Circle selection (APIO18_circle_selection) C++17
0 / 100
207 ms 15844 KB
#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 = 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 * 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 = 0; i < n; i++) {
        if(ans[i] == -1)
            ans[i] = i + 1;
        cout << ans[i] << " ";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 207 ms 15844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 13892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -