답안 #48874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48874 2018-05-19T11:46:10 Z top34051 원 고르기 (APIO18_circle_selection) C++17
0 / 100
3000 ms 408620 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int maxn = 3e5 + 5;

struct node {
    ll x,y,r;
};

int n;
node p[maxn];
ll R;
map<ll,map<ll,vector<int>>> a;
int ok[maxn], res[maxn];

double dist(node a, node b) {
    return sqrt((double)(a.x-b.x)*(a.x-b.x) + (double)(a.y-b.y)*(a.y-b.y));
}

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&p[i].x,&p[i].y,&p[i].r);

    ll R = p[1].r;
    for(int i=1;i<=n;i++) {
        a[p[i].x/R][p[i].y/R].push_back(i);
//        printf("%lld %lld : %d\n",p[i].x/R,p[i].y/R,i);
    }

    for(int x=1;x<=n;x++) {
        if(ok[x]) continue;
//        printf("x = %d\n",x);
        for(ll i=p[x].x/R-2;i<=p[x].x/R+2;i++) {
            for(ll j=p[x].y/R-2;j<=p[x].y/R+2;j++) {
                for(auto y : a[i][j]) {
//                    printf("\ty = %d\n",y);
                    if(ok[y]) continue;
                    if(dist(p[x],p[y])<=(double)R*2) {
                        ok[y] = 1;
                        res[y] = x;
                    }
                }
            }
        }
    }

    for(int x=1;x<=n;x++) printf("%d ",res[x]);
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
circle_selection.cpp:23:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&p[i].x,&p[i].y,&p[i].r);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Incorrect 2 ms 560 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 189 ms 11896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 11896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3071 ms 408620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Incorrect 2 ms 560 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Incorrect 2 ms 560 KB Output isn't correct
5 Halted 0 ms 0 KB -