# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48879 | top34051 | Circle selection (APIO18_circle_selection) | C++17 | 3084 ms | 487460 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.
#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;
ll xx[maxn], yy[maxn];
unordered_map<ll,unordered_map<ll,set<int>>> a;
int ok[maxn], res[maxn];
vector<int> del;
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++) {
xx[i] = p[i].x/R;
yy[i] = p[i].y/R;
a[xx[i]][yy[i]].insert(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=xx[x]-2;i<=xx[x]+2;i++) {
for(ll j=yy[x]-2;j<=yy[x]+2;j++) {
del.clear();
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;
del.push_back(y);
}
}
for(auto y : del) a[i][j].erase(y);
}
}
}
for(int x=1;x<=n;x++) printf("%d ",res[x]);
}
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... |