Submission #139755

# Submission time Handle Problem Language Result Execution time Memory
139755 2019-08-01T11:12:19 Z ae04071 Circle selection (APIO18_circle_selection) C++11
19 / 100
3000 ms 35192 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using pii = pair<int,int>;

const int INF = 1e9;

struct circle{
    int x,y,r,i;
    bool operator<(const circle &rhs)const {
        return r!=rhs.r ? r>rhs.r : i<rhs.i;
    }
    bool touch(circle &rhs)const {
        return 1ll*(x-rhs.x)*(x-rhs.x)+1ll*(y-rhs.y)*(y-rhs.y)<=1ll*(r+rhs.r)*(r+rhs.r);
    }
}arr[300001],o[300001];
int n,chk[300001];

set<pii> tr;

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d%d%d",&arr[i].x,&arr[i].y,&arr[i].r);
        arr[i].i=i;
        tr.insert({arr[i].x,i});
        o[i] = arr[i];
    }
    sort(o+1, o+n+1);
    //sort(arr+1,arr+n+1);

    for(int i=1;i<=n;i++) {
        int idx = o[i].i;
        if(chk[idx]) continue;
        
        chk[idx] = idx;
        tr.erase({o[i].x,idx});
        
        auto it = tr.lower_bound({max(-2ll*INF, o[i].x-2ll*o[i].r), -1});
        vector<pii> ta;
        for(;it!=tr.end() && it->fi-2ll*o[i].r<=o[i].x;it++) {
            ta.push_back({arr[it->se].y, it->se});
        }
        sort(ta.begin(),ta.end());


        auto jt = lower_bound(ta.begin(),ta.end(),pii(max(-2ll*INF, o[i].y-2ll*o[i].r), -1));
        int v = jt - ta.begin();

        for(int j=v; j<sz(ta) && arr[ta[j].se].y-2ll*o[i].r<=o[i].y;j++) {
            if(o[i].touch(arr[ta[j].se])) {
                chk[ta[j].se] = idx;
                tr.erase({arr[ta[j].se].x, ta[j].se});
            }
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",chk[i]);

    return 0;
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
circle_selection.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&arr[i].x,&arr[i].y,&arr[i].r);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 420 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 9 ms 1020 KB Output is correct
20 Correct 9 ms 1016 KB Output is correct
21 Correct 9 ms 1016 KB Output is correct
22 Correct 9 ms 888 KB Output is correct
23 Correct 19 ms 888 KB Output is correct
24 Correct 9 ms 888 KB Output is correct
25 Correct 8 ms 888 KB Output is correct
26 Correct 9 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 689 ms 34784 KB Output is correct
2 Correct 693 ms 35028 KB Output is correct
3 Correct 770 ms 34664 KB Output is correct
4 Correct 681 ms 34756 KB Output is correct
5 Correct 557 ms 31664 KB Output is correct
6 Correct 644 ms 31608 KB Output is correct
7 Correct 553 ms 31760 KB Output is correct
8 Correct 584 ms 31600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 537 ms 11944 KB Output is correct
3 Correct 2087 ms 35192 KB Output is correct
4 Correct 1997 ms 35124 KB Output is correct
5 Execution timed out 3059 ms 32376 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1072 ms 34960 KB Output is correct
2 Correct 612 ms 34008 KB Output is correct
3 Execution timed out 3006 ms 33524 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 420 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 9 ms 1020 KB Output is correct
20 Correct 9 ms 1016 KB Output is correct
21 Correct 9 ms 1016 KB Output is correct
22 Correct 9 ms 888 KB Output is correct
23 Correct 19 ms 888 KB Output is correct
24 Correct 9 ms 888 KB Output is correct
25 Correct 8 ms 888 KB Output is correct
26 Correct 9 ms 888 KB Output is correct
27 Correct 16 ms 1656 KB Output is correct
28 Correct 16 ms 1656 KB Output is correct
29 Correct 16 ms 1656 KB Output is correct
30 Correct 26 ms 1528 KB Output is correct
31 Correct 17 ms 1528 KB Output is correct
32 Correct 17 ms 1532 KB Output is correct
33 Correct 198 ms 12752 KB Output is correct
34 Correct 202 ms 12528 KB Output is correct
35 Correct 215 ms 12644 KB Output is correct
36 Correct 239 ms 11748 KB Output is correct
37 Correct 284 ms 11768 KB Output is correct
38 Correct 300 ms 11748 KB Output is correct
39 Execution timed out 3037 ms 11440 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 420 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 9 ms 1020 KB Output is correct
20 Correct 9 ms 1016 KB Output is correct
21 Correct 9 ms 1016 KB Output is correct
22 Correct 9 ms 888 KB Output is correct
23 Correct 19 ms 888 KB Output is correct
24 Correct 9 ms 888 KB Output is correct
25 Correct 8 ms 888 KB Output is correct
26 Correct 9 ms 888 KB Output is correct
27 Correct 689 ms 34784 KB Output is correct
28 Correct 693 ms 35028 KB Output is correct
29 Correct 770 ms 34664 KB Output is correct
30 Correct 681 ms 34756 KB Output is correct
31 Correct 557 ms 31664 KB Output is correct
32 Correct 644 ms 31608 KB Output is correct
33 Correct 553 ms 31760 KB Output is correct
34 Correct 584 ms 31600 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 537 ms 11944 KB Output is correct
37 Correct 2087 ms 35192 KB Output is correct
38 Correct 1997 ms 35124 KB Output is correct
39 Execution timed out 3059 ms 32376 KB Time limit exceeded
40 Halted 0 ms 0 KB -