# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50001 | top34051 | Circle selection (APIO18_circle_selection) | C++17 | 3082 ms | 508316 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//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++) {
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |