#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define FOR(i,a,b) for (int i=(a),_b=(b); i<=_b; ++i)
#define FORR(i,a,b) for (int i=(a),_b=(b); i>=_b; --i)
#define REP(i,b) for (int i=0,_b=(b); i<_b; ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
int ReadInt()
{
char c;
for (c = getchar(); c!='-'&&(c < '0' || c > '9'); c = getchar());
int nega=0;
int ans = c - '0';
if (c=='-') nega=1,ans=0;
for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
ans = ans * 10 + c - '0';
if (nega) return -ans;
return ans;
}
void WriteInt(int x)
{
if (x > 9) WriteInt(x / 10);
putchar(x % 10 + '0');
}
const int maxn=3e5+5;
inline int64 sqr(int64 x)
{
return x*x;
}
struct Circle{
int64 x,y,r;
int id;
bool IsIntersect(const Circle &c)
{
return sqr(x-c.x)+sqr(y-c.y)<=sqr(r+c.r);
}
}cir[maxn];
bool operator <(const Circle &b,const Circle &c)
{
return mp(-b.r,b.id)<mp(-c.r,c.id);
}
vector<set<pii> > Point;
vector<int> X;
int n;
int ans[maxn];
pii tmp[maxn];
int main()
{
#ifdef meomeomeooooo
freopen("input.txt","r",stdin);
//freopen(".txt","w",stdout);
#endif // meomeomeooooo
iostream::sync_with_stdio(false);
cin.tie(0);
n=ReadInt();
set<Circle> myset;
FOR(i,1,n) {
//cin >> cir[i].x >> cir[i].y >> cir[i].r;
cir[i].x=ReadInt(); cir[i].y=ReadInt(); cir[i].r=ReadInt();
X.push_back(cir[i].x);
cir[i].id=i;
myset.insert(cir[i]);
}
sort(X.begin(),X.end());
X.resize(unique(X.begin(),X.end())-X.begin());
#define GetDec(x) (lower_bound(X.begin(),X.end(),x)-X.begin())
Point.resize(X.size());
FOR(i,1,n) {
int x=GetDec(cir[i].x);
Point[x].insert({cir[i].y,cir[i].id});
}
while (myset.size()) {
Circle cur=*myset.begin(); myset.erase(cur);
ans[cur.id]=cur.id;
int x=cur.x,y=cur.y,r=cur.r;
int Lx=max(1ll*x-2*r,-1000000000ll);
int Rx=min(1ll*x+2*r,1000000000ll);
Lx=GetDec(Lx);
int Ly=max(1ll*y-2*r,-1000000000ll);
int Ry=min(1ll*y+2*r,1000000000ll);
for (int i=Lx; i<X.size()&&X[i]<=Rx; ++i) {
int top=0;
int64 meomeo=sqrt(4ll*r*r-sqr(X[i]-x));
// int Ly=max(1ll*y-meomeo,-1000000000ll);
// int Ry=min(1ll*y+meomeo,1000000000ll);
for (auto j=Point[i].lower_bound(mp(Ly,0)); j!=Point[i].end()&&(*j).fi<=Ry; ++j) {
int id=(*j).se;
if (cur.IsIntersect(cir[id])) {
assert(ans[id]==0||ans[id]==cur.id);
ans[id]=cur.id;
myset.erase(cir[id]);
tmp[++top]=*j;
}
}
FOR(j,1,top)
Point[i].erase(tmp[j]);
}
}
FOR(i,1,n) {
WriteInt(ans[i]); putchar(' ');
}
return 0;
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:92:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=Lx; i<X.size()&&X[i]<=Rx; ++i) {
~^~~~~~~~~
circle_selection.cpp:94:19: warning: unused variable 'meomeo' [-Wunused-variable]
int64 meomeo=sqrt(4ll*r*r-sqr(X[i]-x));
^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
640 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
512 KB |
Output is correct |
19 |
Correct |
10 ms |
1380 KB |
Output is correct |
20 |
Correct |
10 ms |
1480 KB |
Output is correct |
21 |
Correct |
10 ms |
1408 KB |
Output is correct |
22 |
Correct |
10 ms |
1408 KB |
Output is correct |
23 |
Correct |
13 ms |
1408 KB |
Output is correct |
24 |
Correct |
10 ms |
1408 KB |
Output is correct |
25 |
Correct |
12 ms |
1408 KB |
Output is correct |
26 |
Correct |
10 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1254 ms |
65752 KB |
Output is correct |
2 |
Correct |
1229 ms |
66016 KB |
Output is correct |
3 |
Correct |
1227 ms |
65652 KB |
Output is correct |
4 |
Correct |
1301 ms |
66068 KB |
Output is correct |
5 |
Correct |
1066 ms |
61156 KB |
Output is correct |
6 |
Correct |
1165 ms |
65960 KB |
Output is correct |
7 |
Correct |
1167 ms |
64996 KB |
Output is correct |
8 |
Correct |
1065 ms |
65380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
421 ms |
22208 KB |
Output is correct |
3 |
Correct |
1591 ms |
65860 KB |
Output is correct |
4 |
Correct |
1453 ms |
66020 KB |
Output is correct |
5 |
Correct |
2284 ms |
64100 KB |
Output is correct |
6 |
Correct |
811 ms |
34408 KB |
Output is correct |
7 |
Correct |
288 ms |
18288 KB |
Output is correct |
8 |
Correct |
31 ms |
4088 KB |
Output is correct |
9 |
Correct |
1868 ms |
65792 KB |
Output is correct |
10 |
Execution timed out |
3022 ms |
63852 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
868 ms |
65776 KB |
Output is correct |
2 |
Correct |
626 ms |
65764 KB |
Output is correct |
3 |
Correct |
2491 ms |
65416 KB |
Output is correct |
4 |
Correct |
611 ms |
65768 KB |
Output is correct |
5 |
Correct |
613 ms |
65892 KB |
Output is correct |
6 |
Correct |
2120 ms |
65088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
640 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
512 KB |
Output is correct |
19 |
Correct |
10 ms |
1380 KB |
Output is correct |
20 |
Correct |
10 ms |
1480 KB |
Output is correct |
21 |
Correct |
10 ms |
1408 KB |
Output is correct |
22 |
Correct |
10 ms |
1408 KB |
Output is correct |
23 |
Correct |
13 ms |
1408 KB |
Output is correct |
24 |
Correct |
10 ms |
1408 KB |
Output is correct |
25 |
Correct |
12 ms |
1408 KB |
Output is correct |
26 |
Correct |
10 ms |
1408 KB |
Output is correct |
27 |
Correct |
16 ms |
2560 KB |
Output is correct |
28 |
Correct |
14 ms |
2560 KB |
Output is correct |
29 |
Correct |
18 ms |
2680 KB |
Output is correct |
30 |
Correct |
21 ms |
2560 KB |
Output is correct |
31 |
Correct |
18 ms |
2560 KB |
Output is correct |
32 |
Correct |
25 ms |
2560 KB |
Output is correct |
33 |
Correct |
313 ms |
22128 KB |
Output is correct |
34 |
Correct |
313 ms |
22188 KB |
Output is correct |
35 |
Correct |
321 ms |
22100 KB |
Output is correct |
36 |
Correct |
328 ms |
22132 KB |
Output is correct |
37 |
Correct |
315 ms |
22100 KB |
Output is correct |
38 |
Correct |
319 ms |
22088 KB |
Output is correct |
39 |
Correct |
1308 ms |
17520 KB |
Output is correct |
40 |
Correct |
1142 ms |
17516 KB |
Output is correct |
41 |
Correct |
1278 ms |
17520 KB |
Output is correct |
42 |
Correct |
263 ms |
17468 KB |
Output is correct |
43 |
Correct |
178 ms |
22188 KB |
Output is correct |
44 |
Correct |
199 ms |
22256 KB |
Output is correct |
45 |
Correct |
178 ms |
22096 KB |
Output is correct |
46 |
Correct |
209 ms |
22280 KB |
Output is correct |
47 |
Correct |
187 ms |
22124 KB |
Output is correct |
48 |
Correct |
179 ms |
22128 KB |
Output is correct |
49 |
Correct |
182 ms |
22128 KB |
Output is correct |
50 |
Correct |
199 ms |
22176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
640 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
3 ms |
512 KB |
Output is correct |
19 |
Correct |
10 ms |
1380 KB |
Output is correct |
20 |
Correct |
10 ms |
1480 KB |
Output is correct |
21 |
Correct |
10 ms |
1408 KB |
Output is correct |
22 |
Correct |
10 ms |
1408 KB |
Output is correct |
23 |
Correct |
13 ms |
1408 KB |
Output is correct |
24 |
Correct |
10 ms |
1408 KB |
Output is correct |
25 |
Correct |
12 ms |
1408 KB |
Output is correct |
26 |
Correct |
10 ms |
1408 KB |
Output is correct |
27 |
Correct |
1254 ms |
65752 KB |
Output is correct |
28 |
Correct |
1229 ms |
66016 KB |
Output is correct |
29 |
Correct |
1227 ms |
65652 KB |
Output is correct |
30 |
Correct |
1301 ms |
66068 KB |
Output is correct |
31 |
Correct |
1066 ms |
61156 KB |
Output is correct |
32 |
Correct |
1165 ms |
65960 KB |
Output is correct |
33 |
Correct |
1167 ms |
64996 KB |
Output is correct |
34 |
Correct |
1065 ms |
65380 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
421 ms |
22208 KB |
Output is correct |
37 |
Correct |
1591 ms |
65860 KB |
Output is correct |
38 |
Correct |
1453 ms |
66020 KB |
Output is correct |
39 |
Correct |
2284 ms |
64100 KB |
Output is correct |
40 |
Correct |
811 ms |
34408 KB |
Output is correct |
41 |
Correct |
288 ms |
18288 KB |
Output is correct |
42 |
Correct |
31 ms |
4088 KB |
Output is correct |
43 |
Correct |
1868 ms |
65792 KB |
Output is correct |
44 |
Execution timed out |
3022 ms |
63852 KB |
Time limit exceeded |