Submission #260884

# Submission time Handle Problem Language Result Execution time Memory
260884 2020-08-11T06:58:40 Z wiwiho Circle selection (APIO18_circle_selection) C++14
12 / 100
2161 ms 74156 KB
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

const ll MAX = 2147483647;

ll dis(pll a, pll b){
    ll x = a.F - b.F;
    ll y = a.S - b.S;
    return x * x + y *y ;
}

struct Comp{

    bool operator()(pll a, pll b){
        if(a.F == b.F) return a.S < b.S;
        return a.F > b.F;
    }

};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<pair<ll, pll>> c(n);

    for(int i = 0; i < n; i++){
        cin >> c[i].S.F >> c[i].S.S >> c[i].F;
    }
    
    vector<int> a(n);

    set<pll, Comp> pq;
    set<pll> l, r;
    for(int i = 0; i < n; i++){
        pq.insert(mp(c[i].F, i));
        l.insert(mp(c[i].S.F - c[i].F, i));
        r.insert(mp(c[i].S.F + c[i].F, i));
    }

    while(!pq.empty()){
        int now = pq.begin()->S;
        a[now] = now;
        vector<int> tmp;
        auto it = l.lower_bound(mp(c[now].S.F - c[now].F, -1));
        for(auto it2 = it; it2->F <= c[now].S.F + c[now].F; it2++){
            if(it2 == l.end()) break;
            //cerr << "l " << now << " " << it2->F << " " << it2->S << "\n";
            tmp.eb(it2->S);
        }
        it = r.lower_bound(mp(c[now].S.F + c[now].F, MAX));
        it--;
        for(auto it2 = it; it2->F >= c[now].S.F - c[now].F; it2--){
            //cerr << "r " << now << " " << it2->F << " " << it2->S << "\n";
            tmp.eb(it2->S);
            if(it2 == r.begin()) break;
        }
        for(int i : tmp){
            pq.erase(mp(c[i].F, i));
            l.erase(mp(c[i].S.F - c[i].F, i));
            r.erase(mp(c[i].S.F + c[i].F, i));
            a[i] = now;
        }
    }

    for(int i = 0; i < n; i++) cout << a[i] + 1 << " ";
    cout << "\n";

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1959 ms 73848 KB Output is correct
2 Correct 2161 ms 74156 KB Output is correct
3 Correct 2037 ms 73840 KB Output is correct
4 Correct 2119 ms 74096 KB Output is correct
5 Correct 1617 ms 71544 KB Output is correct
6 Correct 1442 ms 71808 KB Output is correct
7 Correct 1510 ms 71940 KB Output is correct
8 Correct 1439 ms 71580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1060 ms 66552 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 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -