Submission #737184

# Submission time Handle Problem Language Result Execution time Memory
737184 2023-05-06T18:06:46 Z Username4132 Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 15052 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using pii=pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)


struct circle{
    int x, y, r, ind;
    circle(int X=0, int Y=0, int R=0) : x(X), y(Y), r(R){}
};

bool operator< (circle a, circle b){
    return a.r!=b.r? a.r>b.r : a.ind<b.ind;
}

const int MAXN=300010, LOG=32, dif[3]={-1, 0, 1};
int n, ans[MAXN];
circle arr[MAXN];
vector<circle> cirList;

bool inters(circle a, circle b){
    long long dx=a.x-b.x, dy=a.y-b.y, sr=a.r+b.r;
    return dx*dx <= sr*sr - dy*dy;
}

void insert(circle c){
    cirList.push_back(c);
}

int check(circle c){
    circle ret; ret.ind=-1;
    for(circle cr:cirList) if(inters(c, cr)) ret=min(ret, cr);
    return ret.ind;
}

int main(){
    scanf("%d", &n);
    forn(i, n) scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r), arr[i].ind=i;
    sort(arr, arr+n);
    forn(i, n){
        int val = check(arr[i]);
        if(val==-1){
            ans[arr[i].ind]=arr[i].ind;
            insert(arr[i]);
        }
        else ans[arr[i].ind]=val;
    }
    forn(i, n) printf("%d ", ans[i]+1);
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
circle_selection.cpp:40:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     forn(i, n) scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r), arr[i].ind=i;
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 5004 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 5008 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5000 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5004 KB Output is correct
15 Correct 3 ms 5008 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 4 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 6 ms 5144 KB Output is correct
20 Correct 5 ms 5204 KB Output is correct
21 Correct 5 ms 5076 KB Output is correct
22 Correct 27 ms 5268 KB Output is correct
23 Correct 26 ms 5256 KB Output is correct
24 Correct 27 ms 5324 KB Output is correct
25 Correct 28 ms 5256 KB Output is correct
26 Correct 28 ms 5364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 8180 KB Output is correct
2 Correct 161 ms 15052 KB Output is correct
3 Correct 165 ms 14692 KB Output is correct
4 Correct 145 ms 14948 KB Output is correct
5 Correct 1679 ms 12924 KB Output is correct
6 Execution timed out 3042 ms 12120 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 3039 ms 9316 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3033 ms 6348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 5004 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 5008 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5000 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5004 KB Output is correct
15 Correct 3 ms 5008 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 4 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 6 ms 5144 KB Output is correct
20 Correct 5 ms 5204 KB Output is correct
21 Correct 5 ms 5076 KB Output is correct
22 Correct 27 ms 5268 KB Output is correct
23 Correct 26 ms 5256 KB Output is correct
24 Correct 27 ms 5324 KB Output is correct
25 Correct 28 ms 5256 KB Output is correct
26 Correct 28 ms 5364 KB Output is correct
27 Correct 8 ms 5332 KB Output is correct
28 Correct 7 ms 5272 KB Output is correct
29 Correct 7 ms 5332 KB Output is correct
30 Correct 87 ms 5772 KB Output is correct
31 Correct 101 ms 5668 KB Output is correct
32 Correct 104 ms 5580 KB Output is correct
33 Correct 51 ms 9072 KB Output is correct
34 Correct 55 ms 9072 KB Output is correct
35 Correct 56 ms 8936 KB Output is correct
36 Execution timed out 3052 ms 9160 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 5004 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 5008 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5000 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5004 KB Output is correct
15 Correct 3 ms 5008 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 4 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 6 ms 5144 KB Output is correct
20 Correct 5 ms 5204 KB Output is correct
21 Correct 5 ms 5076 KB Output is correct
22 Correct 27 ms 5268 KB Output is correct
23 Correct 26 ms 5256 KB Output is correct
24 Correct 27 ms 5324 KB Output is correct
25 Correct 28 ms 5256 KB Output is correct
26 Correct 28 ms 5364 KB Output is correct
27 Correct 138 ms 8180 KB Output is correct
28 Correct 161 ms 15052 KB Output is correct
29 Correct 165 ms 14692 KB Output is correct
30 Correct 145 ms 14948 KB Output is correct
31 Correct 1679 ms 12924 KB Output is correct
32 Execution timed out 3042 ms 12120 KB Time limit exceeded
33 Halted 0 ms 0 KB -