// Null
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const ll Mod = 1000000007LL;
const int N = 3e5 + 10;
const int Inf = 2e9;
int n, x[N], y[N], r[N];
int mk[N];
vector<pii> V[N];
vector<int> U;
void Build(int L){
for(int i = 0; i < (int) U.size(); i++) V[i].clear();
U.clear();
for(int i = 1; i <= n; i++){
if(mk[i]) continue;
U.pb(x[i] / L);
}
sort(all(U)); U.resize(unique(all(U)) - U.begin() );
for(int i = 1; i <= n; i++){
V[lower_bound(all(U), x[i] / L) - U.begin()].pb({y[i] / L, i});
}
for(int i = 0; i < (int) U.size(); i++)
sort(all(V[i]));
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> r[i];
}
vector<int> I(n); iota(all(I), 1);
sort(all(I), [&](int i, int j){
return (r[i] == r[j] ? i < j : r[i] > r[j]);
});
int L = 1 << 31;
Build(L);
for(auto id : I){
if(mk[id]) continue;
if(L*3 >= 4*r[id]) Build(L = r[id]);
int i = x[id] / L;
int j = y[id] / L;
int nei;
for(int pos = lower_bound(all(U), i - 2) - U.begin(); pos < (int) U.size() && U[pos] <= i + 2; pos ++){
for(int posj = lower_bound(all(V[pos]), pii(j - 2, -1)) - V[pos].begin(); posj < (int) V[pos].size() && V[pos][posj].F <= j + 2; posj ++){
nei = V[pos][posj].S;
if(mk[nei]) continue;
if(1ll*(x[id] - x[nei])*(x[id] - x[nei]) + 1ll*(y[id] - y[nei])*(y[id] - y[nei]) <= 1ll*(r[id] + r[nei])*(r[id] + r[nei]) ){
mk[nei] = id;
}
}
}
}
for(int i = 1; i <= n; i++) cout << mk[i] << ' ';
cout << '\n';
return 0;
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7424 KB |
Output is correct |
2 |
Correct |
4 ms |
7424 KB |
Output is correct |
3 |
Correct |
4 ms |
7424 KB |
Output is correct |
4 |
Correct |
4 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7424 KB |
Output is correct |
7 |
Correct |
7 ms |
7424 KB |
Output is correct |
8 |
Correct |
7 ms |
7424 KB |
Output is correct |
9 |
Correct |
8 ms |
7424 KB |
Output is correct |
10 |
Correct |
7 ms |
7424 KB |
Output is correct |
11 |
Correct |
6 ms |
7424 KB |
Output is correct |
12 |
Correct |
7 ms |
7424 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7424 KB |
Output is correct |
15 |
Correct |
4 ms |
7424 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
7 ms |
7424 KB |
Output is correct |
18 |
Correct |
5 ms |
7424 KB |
Output is correct |
19 |
Correct |
9 ms |
7808 KB |
Output is correct |
20 |
Correct |
8 ms |
7808 KB |
Output is correct |
21 |
Correct |
8 ms |
7808 KB |
Output is correct |
22 |
Correct |
103 ms |
7808 KB |
Output is correct |
23 |
Correct |
103 ms |
7812 KB |
Output is correct |
24 |
Correct |
103 ms |
7808 KB |
Output is correct |
25 |
Correct |
107 ms |
7820 KB |
Output is correct |
26 |
Correct |
102 ms |
7808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
214 ms |
20544 KB |
Output is correct |
2 |
Correct |
200 ms |
20200 KB |
Output is correct |
3 |
Correct |
236 ms |
19940 KB |
Output is correct |
4 |
Correct |
207 ms |
20200 KB |
Output is correct |
5 |
Execution timed out |
3097 ms |
18612 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7424 KB |
Output is correct |
2 |
Execution timed out |
3092 ms |
12272 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3094 ms |
19052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7424 KB |
Output is correct |
2 |
Correct |
4 ms |
7424 KB |
Output is correct |
3 |
Correct |
4 ms |
7424 KB |
Output is correct |
4 |
Correct |
4 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7424 KB |
Output is correct |
7 |
Correct |
7 ms |
7424 KB |
Output is correct |
8 |
Correct |
7 ms |
7424 KB |
Output is correct |
9 |
Correct |
8 ms |
7424 KB |
Output is correct |
10 |
Correct |
7 ms |
7424 KB |
Output is correct |
11 |
Correct |
6 ms |
7424 KB |
Output is correct |
12 |
Correct |
7 ms |
7424 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7424 KB |
Output is correct |
15 |
Correct |
4 ms |
7424 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
7 ms |
7424 KB |
Output is correct |
18 |
Correct |
5 ms |
7424 KB |
Output is correct |
19 |
Correct |
9 ms |
7808 KB |
Output is correct |
20 |
Correct |
8 ms |
7808 KB |
Output is correct |
21 |
Correct |
8 ms |
7808 KB |
Output is correct |
22 |
Correct |
103 ms |
7808 KB |
Output is correct |
23 |
Correct |
103 ms |
7812 KB |
Output is correct |
24 |
Correct |
103 ms |
7808 KB |
Output is correct |
25 |
Correct |
107 ms |
7820 KB |
Output is correct |
26 |
Correct |
102 ms |
7808 KB |
Output is correct |
27 |
Correct |
12 ms |
8192 KB |
Output is correct |
28 |
Correct |
13 ms |
8192 KB |
Output is correct |
29 |
Correct |
12 ms |
8192 KB |
Output is correct |
30 |
Correct |
426 ms |
8180 KB |
Output is correct |
31 |
Correct |
422 ms |
8184 KB |
Output is correct |
32 |
Correct |
425 ms |
8184 KB |
Output is correct |
33 |
Correct |
74 ms |
12528 KB |
Output is correct |
34 |
Correct |
73 ms |
12528 KB |
Output is correct |
35 |
Correct |
89 ms |
12528 KB |
Output is correct |
36 |
Execution timed out |
3087 ms |
11888 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7424 KB |
Output is correct |
2 |
Correct |
4 ms |
7424 KB |
Output is correct |
3 |
Correct |
4 ms |
7424 KB |
Output is correct |
4 |
Correct |
4 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7424 KB |
Output is correct |
7 |
Correct |
7 ms |
7424 KB |
Output is correct |
8 |
Correct |
7 ms |
7424 KB |
Output is correct |
9 |
Correct |
8 ms |
7424 KB |
Output is correct |
10 |
Correct |
7 ms |
7424 KB |
Output is correct |
11 |
Correct |
6 ms |
7424 KB |
Output is correct |
12 |
Correct |
7 ms |
7424 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7424 KB |
Output is correct |
15 |
Correct |
4 ms |
7424 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
7 ms |
7424 KB |
Output is correct |
18 |
Correct |
5 ms |
7424 KB |
Output is correct |
19 |
Correct |
9 ms |
7808 KB |
Output is correct |
20 |
Correct |
8 ms |
7808 KB |
Output is correct |
21 |
Correct |
8 ms |
7808 KB |
Output is correct |
22 |
Correct |
103 ms |
7808 KB |
Output is correct |
23 |
Correct |
103 ms |
7812 KB |
Output is correct |
24 |
Correct |
103 ms |
7808 KB |
Output is correct |
25 |
Correct |
107 ms |
7820 KB |
Output is correct |
26 |
Correct |
102 ms |
7808 KB |
Output is correct |
27 |
Correct |
214 ms |
20544 KB |
Output is correct |
28 |
Correct |
200 ms |
20200 KB |
Output is correct |
29 |
Correct |
236 ms |
19940 KB |
Output is correct |
30 |
Correct |
207 ms |
20200 KB |
Output is correct |
31 |
Execution timed out |
3097 ms |
18612 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |