답안 #50004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50004 2018-06-06T05:23:23 Z top34051 원 고르기 (APIO18_circle_selection) C++17
23 / 100
1762 ms 67184 KB
//subtask 4
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 3e5 + 5;
struct node {
    int x,y,r;
};
int n;
node p[maxn];
int R;
int res[maxn];
unordered_map<int,unordered_map<int,vector<int>>> mp;
bool cut(node a, node b) {
    return (ll)(a.x-b.x)*(a.x-b.x) + (ll)(a.y-b.y)*(a.y-b.y) <= (ll)(a.r+b.r)*(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;
        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);
                    }
                }
            }
        }
        if(res[i]==i) {
            mp[x][y].push_back(i);
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",res[i]);
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
circle_selection.cpp:19: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 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Incorrect 3 ms 568 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 387 ms 5872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1762 ms 42760 KB Output is correct
2 Correct 986 ms 67184 KB Output is correct
3 Correct 1352 ms 67184 KB Output is correct
4 Correct 1044 ms 67184 KB Output is correct
5 Correct 978 ms 67184 KB Output is correct
6 Correct 1036 ms 67184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Incorrect 3 ms 568 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Incorrect 3 ms 568 KB Output isn't correct
5 Halted 0 ms 0 KB -