#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<ll> poll;
const ll maxn = 3e5 + 20;
const ll inf = 1e9;
set<pair<ll,ll>> s[maxn];
ll c[maxn], r[maxn];
poll p[maxn];
ll SQ(ll x){
return x*x;
}
ll dis(poll x, poll y){
return SQ(x.real() - y.real()) + SQ(x.imag() - y.imag());
}
int main(){
ios_base::sync_with_stdio(false);
ll n;
cin >> n;
vector<ll> a;
vector<pair<ll,ll>> larger;
for (ll i = 1; i <= n; i++){
ll x, y;
cin >> x >> y >> r[i];
p[i] = poll(x,y);
a.push_back(x);
larger.push_back({r[i],-i});
}
sort(a.begin(), a.end());
a.resize(unique(a.begin(),a.end())-a.begin());
for (ll i = 1; i <= n; i++){
ll x = p[i].real(), y = p[i].imag();
x = lower_bound(a.begin(), a.end(), x) - a.begin();
s[x].insert({y,i});
}
sort(larger.rbegin(), larger.rend());
for (auto it : larger){
ll idx = -it.second;
if (c[idx] != 0)
continue;
ll x = p[idx].real(), y = p[idx].imag();
ll lef = lower_bound(a.begin(), a.end(), x-2*r[idx])-a.begin();
ll rig = upper_bound(a.begin(), a.end(), x+2*r[idx])-a.begin();
for (ll i = lef; i < rig; i++){
vector<ll> dels;
for (auto j = s[i].lower_bound(make_pair(y-2*r[idx],0)); j != s[i].end(); j ++){
ll then = (*j).second;
if (abs(p[then].imag()-p[idx].imag()) > 2*r[idx])
break;
if (dis(p[idx],p[then]) <= SQ(r[idx]+r[then])){
c[then] = idx;
dels.push_back(then);
}
}
for (auto j : dels){
ll x = lower_bound(a.begin(), a.end(), p[j].real()) - a.begin();
s[x].erase({p[j].imag(),j});
}
}
}
for (ll i = 1; i <= n; i++)
cout << c[i] << " \n"[i == n];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14464 KB |
Output is correct |
2 |
Correct |
9 ms |
14464 KB |
Output is correct |
3 |
Correct |
9 ms |
14464 KB |
Output is correct |
4 |
Correct |
9 ms |
14464 KB |
Output is correct |
5 |
Correct |
8 ms |
14464 KB |
Output is correct |
6 |
Correct |
8 ms |
14464 KB |
Output is correct |
7 |
Correct |
9 ms |
14464 KB |
Output is correct |
8 |
Correct |
9 ms |
14464 KB |
Output is correct |
9 |
Correct |
11 ms |
14464 KB |
Output is correct |
10 |
Correct |
9 ms |
14464 KB |
Output is correct |
11 |
Correct |
11 ms |
14464 KB |
Output is correct |
12 |
Correct |
9 ms |
14464 KB |
Output is correct |
13 |
Correct |
9 ms |
14464 KB |
Output is correct |
14 |
Correct |
9 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
10 ms |
14592 KB |
Output is correct |
17 |
Correct |
12 ms |
14592 KB |
Output is correct |
18 |
Correct |
9 ms |
14592 KB |
Output is correct |
19 |
Correct |
14 ms |
15232 KB |
Output is correct |
20 |
Correct |
15 ms |
15224 KB |
Output is correct |
21 |
Correct |
16 ms |
15232 KB |
Output is correct |
22 |
Correct |
15 ms |
15232 KB |
Output is correct |
23 |
Correct |
20 ms |
15232 KB |
Output is correct |
24 |
Correct |
15 ms |
15360 KB |
Output is correct |
25 |
Correct |
17 ms |
15232 KB |
Output is correct |
26 |
Correct |
16 ms |
15232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
438 ms |
58684 KB |
Output is correct |
2 |
Correct |
445 ms |
58676 KB |
Output is correct |
3 |
Correct |
427 ms |
58164 KB |
Output is correct |
4 |
Correct |
435 ms |
58560 KB |
Output is correct |
5 |
Correct |
519 ms |
56252 KB |
Output is correct |
6 |
Correct |
566 ms |
56384 KB |
Output is correct |
7 |
Correct |
504 ms |
56376 KB |
Output is correct |
8 |
Correct |
458 ms |
56384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14464 KB |
Output is correct |
2 |
Correct |
280 ms |
29616 KB |
Output is correct |
3 |
Correct |
1054 ms |
59744 KB |
Output is correct |
4 |
Correct |
1206 ms |
59836 KB |
Output is correct |
5 |
Correct |
1533 ms |
58704 KB |
Output is correct |
6 |
Correct |
596 ms |
38216 KB |
Output is correct |
7 |
Correct |
167 ms |
26848 KB |
Output is correct |
8 |
Correct |
39 ms |
16988 KB |
Output is correct |
9 |
Correct |
1150 ms |
59800 KB |
Output is correct |
10 |
Correct |
2468 ms |
60040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
704 ms |
59600 KB |
Output is correct |
2 |
Correct |
495 ms |
58832 KB |
Output is correct |
3 |
Correct |
1625 ms |
59708 KB |
Output is correct |
4 |
Correct |
529 ms |
59200 KB |
Output is correct |
5 |
Correct |
507 ms |
59328 KB |
Output is correct |
6 |
Correct |
1384 ms |
59508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14464 KB |
Output is correct |
2 |
Correct |
9 ms |
14464 KB |
Output is correct |
3 |
Correct |
9 ms |
14464 KB |
Output is correct |
4 |
Correct |
9 ms |
14464 KB |
Output is correct |
5 |
Correct |
8 ms |
14464 KB |
Output is correct |
6 |
Correct |
8 ms |
14464 KB |
Output is correct |
7 |
Correct |
9 ms |
14464 KB |
Output is correct |
8 |
Correct |
9 ms |
14464 KB |
Output is correct |
9 |
Correct |
11 ms |
14464 KB |
Output is correct |
10 |
Correct |
9 ms |
14464 KB |
Output is correct |
11 |
Correct |
11 ms |
14464 KB |
Output is correct |
12 |
Correct |
9 ms |
14464 KB |
Output is correct |
13 |
Correct |
9 ms |
14464 KB |
Output is correct |
14 |
Correct |
9 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
10 ms |
14592 KB |
Output is correct |
17 |
Correct |
12 ms |
14592 KB |
Output is correct |
18 |
Correct |
9 ms |
14592 KB |
Output is correct |
19 |
Correct |
14 ms |
15232 KB |
Output is correct |
20 |
Correct |
15 ms |
15224 KB |
Output is correct |
21 |
Correct |
16 ms |
15232 KB |
Output is correct |
22 |
Correct |
15 ms |
15232 KB |
Output is correct |
23 |
Correct |
20 ms |
15232 KB |
Output is correct |
24 |
Correct |
15 ms |
15360 KB |
Output is correct |
25 |
Correct |
17 ms |
15232 KB |
Output is correct |
26 |
Correct |
16 ms |
15232 KB |
Output is correct |
27 |
Correct |
19 ms |
15996 KB |
Output is correct |
28 |
Correct |
19 ms |
15996 KB |
Output is correct |
29 |
Correct |
22 ms |
15996 KB |
Output is correct |
30 |
Correct |
24 ms |
16012 KB |
Output is correct |
31 |
Correct |
22 ms |
15996 KB |
Output is correct |
32 |
Correct |
22 ms |
15996 KB |
Output is correct |
33 |
Correct |
139 ms |
29992 KB |
Output is correct |
34 |
Correct |
151 ms |
29924 KB |
Output is correct |
35 |
Correct |
166 ms |
29788 KB |
Output is correct |
36 |
Correct |
198 ms |
29348 KB |
Output is correct |
37 |
Correct |
204 ms |
29408 KB |
Output is correct |
38 |
Correct |
219 ms |
29452 KB |
Output is correct |
39 |
Correct |
954 ms |
27996 KB |
Output is correct |
40 |
Correct |
833 ms |
27872 KB |
Output is correct |
41 |
Correct |
939 ms |
27872 KB |
Output is correct |
42 |
Correct |
181 ms |
28384 KB |
Output is correct |
43 |
Correct |
159 ms |
29408 KB |
Output is correct |
44 |
Correct |
155 ms |
29404 KB |
Output is correct |
45 |
Correct |
155 ms |
29404 KB |
Output is correct |
46 |
Correct |
152 ms |
29412 KB |
Output is correct |
47 |
Correct |
155 ms |
29532 KB |
Output is correct |
48 |
Correct |
159 ms |
29408 KB |
Output is correct |
49 |
Correct |
157 ms |
29408 KB |
Output is correct |
50 |
Correct |
159 ms |
29404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14464 KB |
Output is correct |
2 |
Correct |
9 ms |
14464 KB |
Output is correct |
3 |
Correct |
9 ms |
14464 KB |
Output is correct |
4 |
Correct |
9 ms |
14464 KB |
Output is correct |
5 |
Correct |
8 ms |
14464 KB |
Output is correct |
6 |
Correct |
8 ms |
14464 KB |
Output is correct |
7 |
Correct |
9 ms |
14464 KB |
Output is correct |
8 |
Correct |
9 ms |
14464 KB |
Output is correct |
9 |
Correct |
11 ms |
14464 KB |
Output is correct |
10 |
Correct |
9 ms |
14464 KB |
Output is correct |
11 |
Correct |
11 ms |
14464 KB |
Output is correct |
12 |
Correct |
9 ms |
14464 KB |
Output is correct |
13 |
Correct |
9 ms |
14464 KB |
Output is correct |
14 |
Correct |
9 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
10 ms |
14592 KB |
Output is correct |
17 |
Correct |
12 ms |
14592 KB |
Output is correct |
18 |
Correct |
9 ms |
14592 KB |
Output is correct |
19 |
Correct |
14 ms |
15232 KB |
Output is correct |
20 |
Correct |
15 ms |
15224 KB |
Output is correct |
21 |
Correct |
16 ms |
15232 KB |
Output is correct |
22 |
Correct |
15 ms |
15232 KB |
Output is correct |
23 |
Correct |
20 ms |
15232 KB |
Output is correct |
24 |
Correct |
15 ms |
15360 KB |
Output is correct |
25 |
Correct |
17 ms |
15232 KB |
Output is correct |
26 |
Correct |
16 ms |
15232 KB |
Output is correct |
27 |
Correct |
438 ms |
58684 KB |
Output is correct |
28 |
Correct |
445 ms |
58676 KB |
Output is correct |
29 |
Correct |
427 ms |
58164 KB |
Output is correct |
30 |
Correct |
435 ms |
58560 KB |
Output is correct |
31 |
Correct |
519 ms |
56252 KB |
Output is correct |
32 |
Correct |
566 ms |
56384 KB |
Output is correct |
33 |
Correct |
504 ms |
56376 KB |
Output is correct |
34 |
Correct |
458 ms |
56384 KB |
Output is correct |
35 |
Correct |
9 ms |
14464 KB |
Output is correct |
36 |
Correct |
280 ms |
29616 KB |
Output is correct |
37 |
Correct |
1054 ms |
59744 KB |
Output is correct |
38 |
Correct |
1206 ms |
59836 KB |
Output is correct |
39 |
Correct |
1533 ms |
58704 KB |
Output is correct |
40 |
Correct |
596 ms |
38216 KB |
Output is correct |
41 |
Correct |
167 ms |
26848 KB |
Output is correct |
42 |
Correct |
39 ms |
16988 KB |
Output is correct |
43 |
Correct |
1150 ms |
59800 KB |
Output is correct |
44 |
Correct |
2468 ms |
60040 KB |
Output is correct |
45 |
Correct |
704 ms |
59600 KB |
Output is correct |
46 |
Correct |
495 ms |
58832 KB |
Output is correct |
47 |
Correct |
1625 ms |
59708 KB |
Output is correct |
48 |
Correct |
529 ms |
59200 KB |
Output is correct |
49 |
Correct |
507 ms |
59328 KB |
Output is correct |
50 |
Correct |
1384 ms |
59508 KB |
Output is correct |
51 |
Correct |
19 ms |
15996 KB |
Output is correct |
52 |
Correct |
19 ms |
15996 KB |
Output is correct |
53 |
Correct |
22 ms |
15996 KB |
Output is correct |
54 |
Correct |
24 ms |
16012 KB |
Output is correct |
55 |
Correct |
22 ms |
15996 KB |
Output is correct |
56 |
Correct |
22 ms |
15996 KB |
Output is correct |
57 |
Correct |
139 ms |
29992 KB |
Output is correct |
58 |
Correct |
151 ms |
29924 KB |
Output is correct |
59 |
Correct |
166 ms |
29788 KB |
Output is correct |
60 |
Correct |
198 ms |
29348 KB |
Output is correct |
61 |
Correct |
204 ms |
29408 KB |
Output is correct |
62 |
Correct |
219 ms |
29452 KB |
Output is correct |
63 |
Correct |
954 ms |
27996 KB |
Output is correct |
64 |
Correct |
833 ms |
27872 KB |
Output is correct |
65 |
Correct |
939 ms |
27872 KB |
Output is correct |
66 |
Correct |
181 ms |
28384 KB |
Output is correct |
67 |
Correct |
159 ms |
29408 KB |
Output is correct |
68 |
Correct |
155 ms |
29404 KB |
Output is correct |
69 |
Correct |
155 ms |
29404 KB |
Output is correct |
70 |
Correct |
152 ms |
29412 KB |
Output is correct |
71 |
Correct |
155 ms |
29532 KB |
Output is correct |
72 |
Correct |
159 ms |
29408 KB |
Output is correct |
73 |
Correct |
157 ms |
29408 KB |
Output is correct |
74 |
Correct |
159 ms |
29404 KB |
Output is correct |
75 |
Correct |
462 ms |
60852 KB |
Output is correct |
76 |
Correct |
458 ms |
60744 KB |
Output is correct |
77 |
Correct |
483 ms |
60852 KB |
Output is correct |
78 |
Correct |
437 ms |
60476 KB |
Output is correct |
79 |
Correct |
638 ms |
60348 KB |
Output is correct |
80 |
Correct |
442 ms |
60604 KB |
Output is correct |
81 |
Correct |
903 ms |
59684 KB |
Output is correct |
82 |
Correct |
776 ms |
59572 KB |
Output is correct |
83 |
Correct |
814 ms |
59600 KB |
Output is correct |
84 |
Correct |
1250 ms |
60084 KB |
Output is correct |
85 |
Correct |
834 ms |
59584 KB |
Output is correct |
86 |
Correct |
749 ms |
59700 KB |
Output is correct |
87 |
Execution timed out |
3069 ms |
57772 KB |
Time limit exceeded |
88 |
Halted |
0 ms |
0 KB |
- |