답안 #50002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50002 2018-06-06T05:19:47 Z top34051 원 고르기 (APIO18_circle_selection) C++17
0 / 100
1852 ms 71992 KB
//subtask 4
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
struct node {
    int x,y,r;
};
int n;
node p[maxn];
int R;
int res[maxn];
map<int,map<int,vector<int>>> mp;
double dist(node a, node b) {
    return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
bool cut(node a, node b) {
    return dist(a,b) <= (double)a.r + b.r;
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].r);
    R = p[1].r;
    for(int i=1;i<=n;i++) {
        int x = p[i].x/R, y = p[i].y/R;
        res[i] = i;
        int counter = 0;
        for(int xx=x-2;xx<=x+2;xx++) {
            for(int yy=y-2;yy<=y+2;yy++) {
                if(mp.count(xx)==0) continue;
                if(mp[xx].count(yy)==0) continue;
                for(auto t : mp[xx][yy]) {
                    if(cut(p[i], p[t])) {
                        res[i] = min(res[i], t);
                    }
                    counter++;
                }
            }
        }
        assert(counter<=60);
        if(res[i]==i) {
            mp[x][y].push_back(i);
            assert(mp[x][y].size()<=3);
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",res[i]);
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
circle_selection.cpp:21: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("%d%d%d",&p[i].x,&p[i].y,&p[i].r);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 140 ms 7540 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1852 ms 51396 KB Output is correct
2 Correct 1060 ms 71992 KB Output is correct
3 Runtime error 561 ms 71992 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -