#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
vector <int> x, y, r;
void init() {
cin >> n;
x.resize(n);
y.resize(n);
r.resize(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i] >> r[i];
}
}
bool inter(int i, int j) {
return (ll)(x[i] - x[j]) * (x[i] - x[j]) + (ll)(y[i] - y[j]) * (y[i] - y[j]) <= (ll)(r[i] + r[j]) * (r[i] + r[j]);
}
map <pair <int, int>, vector <int>> who;
set <int> alive;
void rebuild(int B) {
who.clear();
for (auto i : alive) {
int xx = x[i] / B;
int yy = y[i] / B;
who[make_pair(xx, yy)].push_back(i);
}
}
void solve() {
for (int i = 0; i < n; ++i) alive.insert(i);
vector <int> idx(n);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&] (int i, int j) {
if (r[i] != r[j]) return r[i] > r[j];
return i < j;
});
vector <int> kill(n, -1);
int uk = 0;
int B = 2e9 + 7;
while (true) {
while (uk < n && kill[idx[uk]] != -1) ++uk;
if (uk == n) break;
int cur = idx[uk];
if ((r[cur] << 1) <= B) {
B = r[cur];
rebuild(B);
}
alive.erase(cur);
kill[cur] = cur;
int xx = x[cur] / B;
int yy = y[cur] / B;
for (int cx = xx - 2; cx <= xx + 2; ++cx) {
for (int cy = yy - 2; cy <= yy + 2; ++cy) {
vector <int> nw;
for (auto j : who[make_pair(cx, cy)]) {
if (inter(cur, j)) {
kill[j] = cur;
alive.erase(j);
}
else {
nw.push_back(j);
}
}
who[make_pair(cx, cy)] = nw;
}
}
}
for (int i = 0; i < n; ++i) {
cout << kill[i] + 1 << ' ';
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
init();
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
2 ms |
544 KB |
Output is correct |
8 |
Correct |
2 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
3 ms |
616 KB |
Output is correct |
11 |
Correct |
3 ms |
620 KB |
Output is correct |
12 |
Correct |
4 ms |
748 KB |
Output is correct |
13 |
Correct |
3 ms |
764 KB |
Output is correct |
14 |
Correct |
3 ms |
764 KB |
Output is correct |
15 |
Correct |
3 ms |
764 KB |
Output is correct |
16 |
Correct |
3 ms |
764 KB |
Output is correct |
17 |
Correct |
3 ms |
764 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
6 ms |
1020 KB |
Output is correct |
20 |
Correct |
6 ms |
1020 KB |
Output is correct |
21 |
Correct |
6 ms |
1036 KB |
Output is correct |
22 |
Correct |
55 ms |
6176 KB |
Output is correct |
23 |
Correct |
57 ms |
6176 KB |
Output is correct |
24 |
Correct |
61 ms |
6188 KB |
Output is correct |
25 |
Correct |
50 ms |
6188 KB |
Output is correct |
26 |
Correct |
60 ms |
6332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
338 ms |
22796 KB |
Output is correct |
2 |
Correct |
361 ms |
23696 KB |
Output is correct |
3 |
Correct |
335 ms |
24080 KB |
Output is correct |
4 |
Correct |
330 ms |
24080 KB |
Output is correct |
5 |
Correct |
642 ms |
24080 KB |
Output is correct |
6 |
Correct |
2154 ms |
88276 KB |
Output is correct |
7 |
Correct |
796 ms |
88276 KB |
Output is correct |
8 |
Correct |
1020 ms |
88276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
88276 KB |
Output is correct |
2 |
Correct |
1964 ms |
109780 KB |
Output is correct |
3 |
Execution timed out |
3052 ms |
295248 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3088 ms |
347256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
2 ms |
544 KB |
Output is correct |
8 |
Correct |
2 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
3 ms |
616 KB |
Output is correct |
11 |
Correct |
3 ms |
620 KB |
Output is correct |
12 |
Correct |
4 ms |
748 KB |
Output is correct |
13 |
Correct |
3 ms |
764 KB |
Output is correct |
14 |
Correct |
3 ms |
764 KB |
Output is correct |
15 |
Correct |
3 ms |
764 KB |
Output is correct |
16 |
Correct |
3 ms |
764 KB |
Output is correct |
17 |
Correct |
3 ms |
764 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
6 ms |
1020 KB |
Output is correct |
20 |
Correct |
6 ms |
1020 KB |
Output is correct |
21 |
Correct |
6 ms |
1036 KB |
Output is correct |
22 |
Correct |
55 ms |
6176 KB |
Output is correct |
23 |
Correct |
57 ms |
6176 KB |
Output is correct |
24 |
Correct |
61 ms |
6188 KB |
Output is correct |
25 |
Correct |
50 ms |
6188 KB |
Output is correct |
26 |
Correct |
60 ms |
6332 KB |
Output is correct |
27 |
Correct |
11 ms |
347256 KB |
Output is correct |
28 |
Correct |
11 ms |
347256 KB |
Output is correct |
29 |
Correct |
11 ms |
347256 KB |
Output is correct |
30 |
Correct |
145 ms |
347256 KB |
Output is correct |
31 |
Correct |
123 ms |
347256 KB |
Output is correct |
32 |
Correct |
149 ms |
347256 KB |
Output is correct |
33 |
Correct |
108 ms |
347256 KB |
Output is correct |
34 |
Correct |
115 ms |
347256 KB |
Output is correct |
35 |
Correct |
177 ms |
347256 KB |
Output is correct |
36 |
Correct |
1829 ms |
347256 KB |
Output is correct |
37 |
Correct |
1874 ms |
347256 KB |
Output is correct |
38 |
Correct |
1981 ms |
347256 KB |
Output is correct |
39 |
Correct |
804 ms |
347256 KB |
Output is correct |
40 |
Correct |
832 ms |
347256 KB |
Output is correct |
41 |
Correct |
843 ms |
347256 KB |
Output is correct |
42 |
Correct |
456 ms |
347256 KB |
Output is correct |
43 |
Correct |
1401 ms |
347256 KB |
Output is correct |
44 |
Correct |
1422 ms |
347256 KB |
Output is correct |
45 |
Correct |
1383 ms |
347256 KB |
Output is correct |
46 |
Correct |
1400 ms |
347256 KB |
Output is correct |
47 |
Correct |
1409 ms |
347256 KB |
Output is correct |
48 |
Correct |
1401 ms |
347256 KB |
Output is correct |
49 |
Correct |
1373 ms |
347256 KB |
Output is correct |
50 |
Correct |
1379 ms |
347256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
2 ms |
544 KB |
Output is correct |
8 |
Correct |
2 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
3 ms |
616 KB |
Output is correct |
11 |
Correct |
3 ms |
620 KB |
Output is correct |
12 |
Correct |
4 ms |
748 KB |
Output is correct |
13 |
Correct |
3 ms |
764 KB |
Output is correct |
14 |
Correct |
3 ms |
764 KB |
Output is correct |
15 |
Correct |
3 ms |
764 KB |
Output is correct |
16 |
Correct |
3 ms |
764 KB |
Output is correct |
17 |
Correct |
3 ms |
764 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
6 ms |
1020 KB |
Output is correct |
20 |
Correct |
6 ms |
1020 KB |
Output is correct |
21 |
Correct |
6 ms |
1036 KB |
Output is correct |
22 |
Correct |
55 ms |
6176 KB |
Output is correct |
23 |
Correct |
57 ms |
6176 KB |
Output is correct |
24 |
Correct |
61 ms |
6188 KB |
Output is correct |
25 |
Correct |
50 ms |
6188 KB |
Output is correct |
26 |
Correct |
60 ms |
6332 KB |
Output is correct |
27 |
Correct |
338 ms |
22796 KB |
Output is correct |
28 |
Correct |
361 ms |
23696 KB |
Output is correct |
29 |
Correct |
335 ms |
24080 KB |
Output is correct |
30 |
Correct |
330 ms |
24080 KB |
Output is correct |
31 |
Correct |
642 ms |
24080 KB |
Output is correct |
32 |
Correct |
2154 ms |
88276 KB |
Output is correct |
33 |
Correct |
796 ms |
88276 KB |
Output is correct |
34 |
Correct |
1020 ms |
88276 KB |
Output is correct |
35 |
Correct |
3 ms |
88276 KB |
Output is correct |
36 |
Correct |
1964 ms |
109780 KB |
Output is correct |
37 |
Execution timed out |
3052 ms |
295248 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |