#include <bits/stdc++.h>
#include <experimental/random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <windows.h>
// #pragma comment(lib, "shell32")
// ShellExecute(0, "open", your_url, NULL, NULL, SW_SHOWDEFAULT)
using namespace std;
using namespace __gnu_pbds;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
const int MOD = 998244353;
const int INF = 1e9;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
void solve();
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int qwerty = 1;
// cin >> qwerty;
while (qwerty--) {
solve();
}
}
struct circle {
int x, y, r, ind;
};
bool cmp(circle a, circle b) {
return a.r > b.r || (a.r == b.r && a.ind < b.ind);
}
bool per(circle a, circle b) {
return 1ll * (a.x - b.x) * (a.x - b.x) + 1ll * (a.y - b.y) * (a.y - b.y) <= 1ll * (a.r + b.r) * (a.r + b.r);
}
void solve() {
int n;
cin >> n;
vector<circle> cs(n);
for (int i = 0; i < n; i++) {
cin >> cs[i].x >> cs[i].y >> cs[i].r;
cs[i].ind = i;
}
sort(cs.begin(), cs.end(), cmp);
vector<int> ans(n, -1);
for (int for_r = 30; for_r >= 0; for_r--) {
int r = (1 << for_r);
map<pair<int, int>, vector<int>> mp;
bool flag = false;
for (int i = 0; i < n; ++i) {
if (ans[cs[i].ind] == -1 && cs[i].r >= r / 2 && cs[i].r <= r) {
flag = true;
break;
}
}
if (!flag) continue;
for (int i = 0; i < n; i++) {
if (ans[cs[i].ind] == -1) {
mp[{cs[i].x / r, cs[i].y / r}].push_back(i);
}
}
for (int i = 0; i < n; i++) {
if (cs[i].r < r / 2) break;
if (cs[i].r > r || ans[cs[i].ind] != -1) continue;
for (int x = cs[i].x / r - 2; x <= cs[i].x / r + 2; x++) {
for (int y = cs[i].y / r - 2; y <= cs[i].y / r + 2; y++) {
vector<int> &now = mp[{x, y}];
for (int j = (int) now.size() - 1; j >= 0; j--) {
int jj = now[j];
if (per(cs[i], cs[jj])) {
ans[cs[jj].ind] = cs[i].ind;
swap(now[j], now.back());
now.pop_back();
}
}
}
}
}
}
for (int i: ans) {
cout << i + 1 << ' ';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
592 KB |
Output is correct |
22 |
Correct |
26 ms |
4944 KB |
Output is correct |
23 |
Correct |
30 ms |
5244 KB |
Output is correct |
24 |
Correct |
30 ms |
4176 KB |
Output is correct |
25 |
Correct |
28 ms |
4988 KB |
Output is correct |
26 |
Correct |
26 ms |
5276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
9424 KB |
Output is correct |
2 |
Correct |
117 ms |
9252 KB |
Output is correct |
3 |
Correct |
129 ms |
12104 KB |
Output is correct |
4 |
Correct |
115 ms |
12996 KB |
Output is correct |
5 |
Correct |
174 ms |
12104 KB |
Output is correct |
6 |
Correct |
887 ms |
59708 KB |
Output is correct |
7 |
Correct |
227 ms |
16712 KB |
Output is correct |
8 |
Correct |
308 ms |
26696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1062 ms |
88540 KB |
Output is correct |
3 |
Execution timed out |
3075 ms |
234580 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3143 ms |
606016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
592 KB |
Output is correct |
22 |
Correct |
26 ms |
4944 KB |
Output is correct |
23 |
Correct |
30 ms |
5244 KB |
Output is correct |
24 |
Correct |
30 ms |
4176 KB |
Output is correct |
25 |
Correct |
28 ms |
4988 KB |
Output is correct |
26 |
Correct |
26 ms |
5276 KB |
Output is correct |
27 |
Correct |
5 ms |
932 KB |
Output is correct |
28 |
Correct |
4 ms |
1272 KB |
Output is correct |
29 |
Correct |
4 ms |
592 KB |
Output is correct |
30 |
Correct |
57 ms |
10696 KB |
Output is correct |
31 |
Correct |
53 ms |
10824 KB |
Output is correct |
32 |
Correct |
52 ms |
8264 KB |
Output is correct |
33 |
Correct |
41 ms |
5952 KB |
Output is correct |
34 |
Correct |
39 ms |
3136 KB |
Output is correct |
35 |
Correct |
45 ms |
5688 KB |
Output is correct |
36 |
Correct |
874 ms |
96588 KB |
Output is correct |
37 |
Correct |
988 ms |
85112 KB |
Output is correct |
38 |
Correct |
1091 ms |
97852 KB |
Output is correct |
39 |
Correct |
243 ms |
10840 KB |
Output is correct |
40 |
Correct |
245 ms |
10940 KB |
Output is correct |
41 |
Correct |
248 ms |
11624 KB |
Output is correct |
42 |
Correct |
131 ms |
10836 KB |
Output is correct |
43 |
Correct |
769 ms |
177224 KB |
Output is correct |
44 |
Correct |
767 ms |
176104 KB |
Output is correct |
45 |
Correct |
737 ms |
177480 KB |
Output is correct |
46 |
Correct |
776 ms |
175944 KB |
Output is correct |
47 |
Correct |
797 ms |
176340 KB |
Output is correct |
48 |
Correct |
700 ms |
176200 KB |
Output is correct |
49 |
Correct |
688 ms |
178784 KB |
Output is correct |
50 |
Correct |
692 ms |
178664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
592 KB |
Output is correct |
21 |
Correct |
3 ms |
592 KB |
Output is correct |
22 |
Correct |
26 ms |
4944 KB |
Output is correct |
23 |
Correct |
30 ms |
5244 KB |
Output is correct |
24 |
Correct |
30 ms |
4176 KB |
Output is correct |
25 |
Correct |
28 ms |
4988 KB |
Output is correct |
26 |
Correct |
26 ms |
5276 KB |
Output is correct |
27 |
Correct |
115 ms |
9424 KB |
Output is correct |
28 |
Correct |
117 ms |
9252 KB |
Output is correct |
29 |
Correct |
129 ms |
12104 KB |
Output is correct |
30 |
Correct |
115 ms |
12996 KB |
Output is correct |
31 |
Correct |
174 ms |
12104 KB |
Output is correct |
32 |
Correct |
887 ms |
59708 KB |
Output is correct |
33 |
Correct |
227 ms |
16712 KB |
Output is correct |
34 |
Correct |
308 ms |
26696 KB |
Output is correct |
35 |
Correct |
1 ms |
504 KB |
Output is correct |
36 |
Correct |
1062 ms |
88540 KB |
Output is correct |
37 |
Execution timed out |
3075 ms |
234580 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |