Submission #364614

# Submission time Handle Problem Language Result Execution time Memory
364614 2021-02-09T14:43:36 Z doowey Circle selection (APIO18_circle_selection) C++14
72 / 100
3000 ms 70392 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)3e5 + 10;
ll cut = (1ll << 31);
int sol[N];
ll xi[N];
ll yi[N];
ll ri[N];

ll sq(ll v){
    return v * 1ll * v;
}

bool check(int i, int j){
    // sqrt((xi-xj)^2+(yi-yj)^2) <= (ri + rj)
    ll val = sq(xi[i] - xi[j]) + sq(yi[i] - yi[j]);
    ll cmp = sq(ri[i] + ri[j]);
    if(val <= cmp)
        return true;
    return false;
}

map<pii, int> idx;
set<int> V[N];
int cid;

void add(pii x){
    if(idx.count(x)) return;
    idx[x]=cid;
    cid++;
}

int main(){
    fastIO;
    int n;
    cin >> n;
    vector<pii> cir;
    for(int i = 1; i <= n; i ++ ){
        cin >> xi[i] >> yi[i] >> ri[i];
        cir.push_back({ri[i], -i});
    }
    sort(cir.begin(), cir.end());
    int id;
    bool has;
    ll ci, cj;
    int gg;
    for(int i = cir.size() - 1; i >= 0 ;i -- ){
        id = -cir[i].se;
        if(sol[id] == 0){
            has=false;
            while(cut/2ll >= ri[id]){
                has=true;
                cut /= 2ll;
            }

            if(has){
                idx.clear();
                for(int i = 0 ; i < cid; i ++ ){
                    V[i].clear();
                }
                cid = 0;
                for(int i = 1; i <= n; i ++ ){
                    if(sol[i] == 0){
                        add(mp(xi[i]/cut, yi[i]/cut));
                        V[idx[mp(xi[i]/cut,yi[i]/cut)]].insert(i);
                    }
                }
            }
            ci = xi[id]/cut;
            cj = yi[id]/cut;
            for(ll p = -2; p <= 2; p ++ ){
                for(ll q = -2 ; q <= 2; q ++ ){
                    if(idx.count(mp(ci+p,cj+q))){
                        gg = idx[mp(ci + p, cj + q)];
                        vector<int> del;
                        for(auto x : V[gg]){
                            if(check(id, x)){
                                del.push_back(x);
                            }
                        }
                        for(auto q : del){
                            V[gg].erase(q);
                            sol[q]=id;
                        }
                    }
                }
            }
        }
    }
    for(int i = 1; i <= n; i ++ ){
        cout << sol[i] << " ";
    }
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 10 ms 14444 KB Output is correct
4 Correct 12 ms 14444 KB Output is correct
5 Correct 11 ms 14496 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
7 Correct 10 ms 14444 KB Output is correct
8 Correct 10 ms 14444 KB Output is correct
9 Correct 10 ms 14444 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 10 ms 14444 KB Output is correct
12 Correct 10 ms 14444 KB Output is correct
13 Correct 10 ms 14444 KB Output is correct
14 Correct 10 ms 14444 KB Output is correct
15 Correct 10 ms 14444 KB Output is correct
16 Correct 13 ms 14572 KB Output is correct
17 Correct 12 ms 14572 KB Output is correct
18 Correct 13 ms 14572 KB Output is correct
19 Correct 14 ms 15084 KB Output is correct
20 Correct 14 ms 15084 KB Output is correct
21 Correct 16 ms 15084 KB Output is correct
22 Correct 27 ms 15340 KB Output is correct
23 Correct 31 ms 15340 KB Output is correct
24 Correct 32 ms 15340 KB Output is correct
25 Correct 26 ms 15340 KB Output is correct
26 Correct 28 ms 15340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 53720 KB Output is correct
2 Correct 296 ms 51152 KB Output is correct
3 Correct 276 ms 51948 KB Output is correct
4 Correct 281 ms 53584 KB Output is correct
5 Correct 605 ms 48376 KB Output is correct
6 Correct 1155 ms 55356 KB Output is correct
7 Correct 672 ms 48848 KB Output is correct
8 Correct 735 ms 50256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14444 KB Output is correct
2 Correct 761 ms 33124 KB Output is correct
3 Correct 2662 ms 70392 KB Output is correct
4 Correct 2674 ms 70340 KB Output is correct
5 Correct 2903 ms 66660 KB Output is correct
6 Correct 1042 ms 41436 KB Output is correct
7 Correct 472 ms 28556 KB Output is correct
8 Correct 54 ms 17516 KB Output is correct
9 Execution timed out 3083 ms 68796 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1987 ms 62224 KB Output is correct
2 Correct 1342 ms 69492 KB Output is correct
3 Correct 808 ms 55376 KB Output is correct
4 Correct 1430 ms 69712 KB Output is correct
5 Correct 1380 ms 70056 KB Output is correct
6 Correct 624 ms 51920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 10 ms 14444 KB Output is correct
4 Correct 12 ms 14444 KB Output is correct
5 Correct 11 ms 14496 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
7 Correct 10 ms 14444 KB Output is correct
8 Correct 10 ms 14444 KB Output is correct
9 Correct 10 ms 14444 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 10 ms 14444 KB Output is correct
12 Correct 10 ms 14444 KB Output is correct
13 Correct 10 ms 14444 KB Output is correct
14 Correct 10 ms 14444 KB Output is correct
15 Correct 10 ms 14444 KB Output is correct
16 Correct 13 ms 14572 KB Output is correct
17 Correct 12 ms 14572 KB Output is correct
18 Correct 13 ms 14572 KB Output is correct
19 Correct 14 ms 15084 KB Output is correct
20 Correct 14 ms 15084 KB Output is correct
21 Correct 16 ms 15084 KB Output is correct
22 Correct 27 ms 15340 KB Output is correct
23 Correct 31 ms 15340 KB Output is correct
24 Correct 32 ms 15340 KB Output is correct
25 Correct 26 ms 15340 KB Output is correct
26 Correct 28 ms 15340 KB Output is correct
27 Correct 17 ms 15472 KB Output is correct
28 Correct 18 ms 15472 KB Output is correct
29 Correct 17 ms 15472 KB Output is correct
30 Correct 48 ms 15984 KB Output is correct
31 Correct 50 ms 15984 KB Output is correct
32 Correct 48 ms 15984 KB Output is correct
33 Correct 100 ms 24932 KB Output is correct
34 Correct 101 ms 24932 KB Output is correct
35 Correct 101 ms 24548 KB Output is correct
36 Correct 696 ms 30308 KB Output is correct
37 Correct 652 ms 30436 KB Output is correct
38 Correct 744 ms 30308 KB Output is correct
39 Correct 911 ms 29552 KB Output is correct
40 Correct 882 ms 29412 KB Output is correct
41 Correct 939 ms 29600 KB Output is correct
42 Correct 396 ms 27876 KB Output is correct
43 Correct 367 ms 30180 KB Output is correct
44 Correct 390 ms 30180 KB Output is correct
45 Correct 377 ms 30308 KB Output is correct
46 Correct 370 ms 30180 KB Output is correct
47 Correct 370 ms 30308 KB Output is correct
48 Correct 415 ms 30308 KB Output is correct
49 Correct 375 ms 30180 KB Output is correct
50 Correct 368 ms 30180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14444 KB Output is correct
2 Correct 11 ms 14444 KB Output is correct
3 Correct 10 ms 14444 KB Output is correct
4 Correct 12 ms 14444 KB Output is correct
5 Correct 11 ms 14496 KB Output is correct
6 Correct 10 ms 14444 KB Output is correct
7 Correct 10 ms 14444 KB Output is correct
8 Correct 10 ms 14444 KB Output is correct
9 Correct 10 ms 14444 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 10 ms 14444 KB Output is correct
12 Correct 10 ms 14444 KB Output is correct
13 Correct 10 ms 14444 KB Output is correct
14 Correct 10 ms 14444 KB Output is correct
15 Correct 10 ms 14444 KB Output is correct
16 Correct 13 ms 14572 KB Output is correct
17 Correct 12 ms 14572 KB Output is correct
18 Correct 13 ms 14572 KB Output is correct
19 Correct 14 ms 15084 KB Output is correct
20 Correct 14 ms 15084 KB Output is correct
21 Correct 16 ms 15084 KB Output is correct
22 Correct 27 ms 15340 KB Output is correct
23 Correct 31 ms 15340 KB Output is correct
24 Correct 32 ms 15340 KB Output is correct
25 Correct 26 ms 15340 KB Output is correct
26 Correct 28 ms 15340 KB Output is correct
27 Correct 289 ms 53720 KB Output is correct
28 Correct 296 ms 51152 KB Output is correct
29 Correct 276 ms 51948 KB Output is correct
30 Correct 281 ms 53584 KB Output is correct
31 Correct 605 ms 48376 KB Output is correct
32 Correct 1155 ms 55356 KB Output is correct
33 Correct 672 ms 48848 KB Output is correct
34 Correct 735 ms 50256 KB Output is correct
35 Correct 10 ms 14444 KB Output is correct
36 Correct 761 ms 33124 KB Output is correct
37 Correct 2662 ms 70392 KB Output is correct
38 Correct 2674 ms 70340 KB Output is correct
39 Correct 2903 ms 66660 KB Output is correct
40 Correct 1042 ms 41436 KB Output is correct
41 Correct 472 ms 28556 KB Output is correct
42 Correct 54 ms 17516 KB Output is correct
43 Execution timed out 3083 ms 68796 KB Time limit exceeded
44 Halted 0 ms 0 KB -