#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define inf 1000000000000000000
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()
struct circle {
ll x,y,r,id;
} ;
vector< circle > inp;
vi vis;
vii endp,endpy;
circle _;
ll n;
bool mysort(circle a, circle b){
if (a.r == b.r) return a.id < b.id;
return a.r > b.r;
}
ld dist(ll i, ll j){
ll dx = inp[i].x-inp[j].x, dy = inp[i].y-inp[j].y;
return sqrt(ld(dx*dx)+ld(dy*dy));
}
int main(){
cin >> n; inp.assign(n,_);
rep(i,0,n){
cin >> inp[i].x >> inp[i].y >> inp[i].r;
inp[i].id = i;
}
sort(all(inp),mysort);
rep(i,0,n){
endp.push_back(make_pair(inp[i].x-inp[i].r,i));
endp.push_back(make_pair(inp[i].x+inp[i].r,i));
endpy.push_back(make_pair(inp[i].y-inp[i].r,i));
endpy.push_back(make_pair(inp[i].y+inp[i].r,i));
}
sort(all(endp));
if (n <= 10000){
vis.assign(n,-1);
rep(i,0,n){
if (vis[i] != -1) continue;
rep(j,0,n){
if (vis[j] != -1) continue;
if (dist(i,j) <= inp[i].r+inp[j].r) vis[j] = inp[i].id;
}
}
} else {
vis.assign(n,-1);
rep(i,0,n){
if (vis[i] != -1) continue;
ll lo = lower_bound(all(endp),make_pair(inp[i].x-inp[i].r,0LL))-endp.begin();
while (endp[lo].first <= inp[i].x+inp[i].r){
if (vis[endp[lo].second] == -1) vis[endp[lo].second] = i;
lo++;
}
}
}
vi res; res.assign(n,0);
rep(i,0,n){
res[inp[i].id] = vis[i];
}
rep(i,0,n) cout << res[i]+1 << " ";
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
2 ms |
432 KB |
Output is correct |
5 |
Correct |
4 ms |
696 KB |
Output is correct |
6 |
Correct |
3 ms |
696 KB |
Output is correct |
7 |
Correct |
3 ms |
696 KB |
Output is correct |
8 |
Correct |
4 ms |
696 KB |
Output is correct |
9 |
Correct |
4 ms |
716 KB |
Output is correct |
10 |
Correct |
4 ms |
716 KB |
Output is correct |
11 |
Correct |
3 ms |
716 KB |
Output is correct |
12 |
Correct |
4 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
4 ms |
744 KB |
Output is correct |
15 |
Correct |
4 ms |
744 KB |
Output is correct |
16 |
Correct |
6 ms |
800 KB |
Output is correct |
17 |
Correct |
6 ms |
828 KB |
Output is correct |
18 |
Correct |
5 ms |
972 KB |
Output is correct |
19 |
Correct |
20 ms |
1540 KB |
Output is correct |
20 |
Correct |
13 ms |
1540 KB |
Output is correct |
21 |
Correct |
14 ms |
1540 KB |
Output is correct |
22 |
Correct |
155 ms |
1660 KB |
Output is correct |
23 |
Correct |
180 ms |
1676 KB |
Output is correct |
24 |
Correct |
149 ms |
1676 KB |
Output is correct |
25 |
Correct |
155 ms |
1692 KB |
Output is correct |
26 |
Correct |
177 ms |
1692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
703 ms |
35196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
35196 KB |
Output is correct |
2 |
Incorrect |
231 ms |
35196 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
755 ms |
35560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
2 ms |
432 KB |
Output is correct |
5 |
Correct |
4 ms |
696 KB |
Output is correct |
6 |
Correct |
3 ms |
696 KB |
Output is correct |
7 |
Correct |
3 ms |
696 KB |
Output is correct |
8 |
Correct |
4 ms |
696 KB |
Output is correct |
9 |
Correct |
4 ms |
716 KB |
Output is correct |
10 |
Correct |
4 ms |
716 KB |
Output is correct |
11 |
Correct |
3 ms |
716 KB |
Output is correct |
12 |
Correct |
4 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
4 ms |
744 KB |
Output is correct |
15 |
Correct |
4 ms |
744 KB |
Output is correct |
16 |
Correct |
6 ms |
800 KB |
Output is correct |
17 |
Correct |
6 ms |
828 KB |
Output is correct |
18 |
Correct |
5 ms |
972 KB |
Output is correct |
19 |
Correct |
20 ms |
1540 KB |
Output is correct |
20 |
Correct |
13 ms |
1540 KB |
Output is correct |
21 |
Correct |
14 ms |
1540 KB |
Output is correct |
22 |
Correct |
155 ms |
1660 KB |
Output is correct |
23 |
Correct |
180 ms |
1676 KB |
Output is correct |
24 |
Correct |
149 ms |
1676 KB |
Output is correct |
25 |
Correct |
155 ms |
1692 KB |
Output is correct |
26 |
Correct |
177 ms |
1692 KB |
Output is correct |
27 |
Correct |
30 ms |
35560 KB |
Output is correct |
28 |
Correct |
40 ms |
35560 KB |
Output is correct |
29 |
Correct |
36 ms |
35560 KB |
Output is correct |
30 |
Correct |
675 ms |
35560 KB |
Output is correct |
31 |
Correct |
631 ms |
35560 KB |
Output is correct |
32 |
Correct |
698 ms |
35560 KB |
Output is correct |
33 |
Incorrect |
250 ms |
35560 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
2 ms |
432 KB |
Output is correct |
5 |
Correct |
4 ms |
696 KB |
Output is correct |
6 |
Correct |
3 ms |
696 KB |
Output is correct |
7 |
Correct |
3 ms |
696 KB |
Output is correct |
8 |
Correct |
4 ms |
696 KB |
Output is correct |
9 |
Correct |
4 ms |
716 KB |
Output is correct |
10 |
Correct |
4 ms |
716 KB |
Output is correct |
11 |
Correct |
3 ms |
716 KB |
Output is correct |
12 |
Correct |
4 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
4 ms |
744 KB |
Output is correct |
15 |
Correct |
4 ms |
744 KB |
Output is correct |
16 |
Correct |
6 ms |
800 KB |
Output is correct |
17 |
Correct |
6 ms |
828 KB |
Output is correct |
18 |
Correct |
5 ms |
972 KB |
Output is correct |
19 |
Correct |
20 ms |
1540 KB |
Output is correct |
20 |
Correct |
13 ms |
1540 KB |
Output is correct |
21 |
Correct |
14 ms |
1540 KB |
Output is correct |
22 |
Correct |
155 ms |
1660 KB |
Output is correct |
23 |
Correct |
180 ms |
1676 KB |
Output is correct |
24 |
Correct |
149 ms |
1676 KB |
Output is correct |
25 |
Correct |
155 ms |
1692 KB |
Output is correct |
26 |
Correct |
177 ms |
1692 KB |
Output is correct |
27 |
Incorrect |
703 ms |
35196 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |