# include <stdio.h>
# include <bits/stdc++.h>
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y) for (int i = x; i <= y; i ++)
#define FOr(i,x,y) for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to... Red
using namespace std;
inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }
inline bool isvowel (char c) {
c = tolower(c);
if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
return 0;
}
const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int n, m, k;
int id[N];
ll r[N];
ll x[N];
ll y[N];
int ans[N];
int lim;
bool cmp (int x, int y) { return r[x] > r[y] || (r[x] == r[y] && x < y); }
vector < int > q[N];
ll f (int x, int y) {
return x * 5e9l + y;
}
vector < ll > vl;
int was[N], timer;
int get (int x, int y) {
return lower_bound(every(vl), f(x, y)) - vl.begin();
}
void upd () {
vl.clear();
timer ++;
for (int i = 1; i <= n; i ++) {
if (!ans[i]) {
vl.pb(f(x[i] / lim, y[i] / lim));
}
}
sort(every(vl));
for (int i = 1; i <= n; i ++) {
if (!ans[i]) {
if (was[get(x[i] / lim, y[i] / lim)] != timer) q[get(x[i] / lim, y[i] / lim)].clear();
q[get(x[i] / lim, y[i] / lim)].pb(i);
was[get(x[i] / lim, y[i] / lim)] = timer;
}
}
}
ll sq (ll x) { return x * x; }
bool in (int i, int j) {
return sq(x[i] - x[j]) + sq(y[i] - y[j]) <= sq(r[i] + r[j]);
}
int main () {
SpeedForce;
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> x[i] >> y[i] >> r[i];
id[i] = i;
}
sort(id + 1, id + n + 1, &cmp);
lim = inf - 1;
vector < int > nq;
for (int pos = 1, j, xx, yy; pos <= n; pos ++) {
j = id[pos];
if (ans[j]) continue;
if (r[j] * 2 <= lim) {
lim = r[j];
upd ();
}
ans[j] = j;
xx = x[j] / lim, yy = y[j] / lim;
for(int x = xx - 2; x <= xx + 2; x ++) {
for(int y = yy - 2; y <= yy + 2; y ++) {
if (was[(get(x, y))] == timer) {
nq.clear();
for (auto i : q[get(x, y)]) {
if (ans[i]) continue;
if(in(i, j)) {
ans[i] = j;
} else {
nq.push_back(i);
}
}
q[get(x, y)].swap(nq);
}
}
}
}
for (int i = 1; i <= n; i ++)
cout << ans[i] << ' ';
return Accepted;
}
// B...a D....
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
9 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
9 ms |
7424 KB |
Output is correct |
6 |
Correct |
10 ms |
7424 KB |
Output is correct |
7 |
Correct |
9 ms |
7424 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
9 ms |
7424 KB |
Output is correct |
10 |
Correct |
8 ms |
7424 KB |
Output is correct |
11 |
Correct |
8 ms |
7424 KB |
Output is correct |
12 |
Correct |
9 ms |
7424 KB |
Output is correct |
13 |
Correct |
9 ms |
7424 KB |
Output is correct |
14 |
Correct |
10 ms |
7424 KB |
Output is correct |
15 |
Correct |
13 ms |
7424 KB |
Output is correct |
16 |
Correct |
9 ms |
7424 KB |
Output is correct |
17 |
Correct |
13 ms |
7552 KB |
Output is correct |
18 |
Correct |
10 ms |
7424 KB |
Output is correct |
19 |
Correct |
13 ms |
7808 KB |
Output is correct |
20 |
Correct |
16 ms |
7808 KB |
Output is correct |
21 |
Correct |
14 ms |
7808 KB |
Output is correct |
22 |
Correct |
31 ms |
7928 KB |
Output is correct |
23 |
Correct |
44 ms |
7936 KB |
Output is correct |
24 |
Correct |
32 ms |
7936 KB |
Output is correct |
25 |
Correct |
28 ms |
7936 KB |
Output is correct |
26 |
Correct |
30 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
265 ms |
24800 KB |
Output is correct |
2 |
Correct |
273 ms |
23648 KB |
Output is correct |
3 |
Correct |
265 ms |
23392 KB |
Output is correct |
4 |
Correct |
263 ms |
24720 KB |
Output is correct |
5 |
Correct |
453 ms |
24412 KB |
Output is correct |
6 |
Correct |
1087 ms |
28272 KB |
Output is correct |
7 |
Correct |
598 ms |
24928 KB |
Output is correct |
8 |
Correct |
679 ms |
25572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
696 ms |
15708 KB |
Output is correct |
3 |
Correct |
2591 ms |
32068 KB |
Output is correct |
4 |
Correct |
2655 ms |
32224 KB |
Output is correct |
5 |
Correct |
2443 ms |
31212 KB |
Output is correct |
6 |
Correct |
887 ms |
19816 KB |
Output is correct |
7 |
Correct |
379 ms |
13936 KB |
Output is correct |
8 |
Correct |
66 ms |
8952 KB |
Output is correct |
9 |
Correct |
2725 ms |
32148 KB |
Output is correct |
10 |
Correct |
2079 ms |
38624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2083 ms |
31980 KB |
Output is correct |
2 |
Correct |
1506 ms |
32220 KB |
Output is correct |
3 |
Correct |
692 ms |
25920 KB |
Output is correct |
4 |
Correct |
1586 ms |
32240 KB |
Output is correct |
5 |
Correct |
1647 ms |
32096 KB |
Output is correct |
6 |
Correct |
482 ms |
24288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
9 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
9 ms |
7424 KB |
Output is correct |
6 |
Correct |
10 ms |
7424 KB |
Output is correct |
7 |
Correct |
9 ms |
7424 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
9 ms |
7424 KB |
Output is correct |
10 |
Correct |
8 ms |
7424 KB |
Output is correct |
11 |
Correct |
8 ms |
7424 KB |
Output is correct |
12 |
Correct |
9 ms |
7424 KB |
Output is correct |
13 |
Correct |
9 ms |
7424 KB |
Output is correct |
14 |
Correct |
10 ms |
7424 KB |
Output is correct |
15 |
Correct |
13 ms |
7424 KB |
Output is correct |
16 |
Correct |
9 ms |
7424 KB |
Output is correct |
17 |
Correct |
13 ms |
7552 KB |
Output is correct |
18 |
Correct |
10 ms |
7424 KB |
Output is correct |
19 |
Correct |
13 ms |
7808 KB |
Output is correct |
20 |
Correct |
16 ms |
7808 KB |
Output is correct |
21 |
Correct |
14 ms |
7808 KB |
Output is correct |
22 |
Correct |
31 ms |
7928 KB |
Output is correct |
23 |
Correct |
44 ms |
7936 KB |
Output is correct |
24 |
Correct |
32 ms |
7936 KB |
Output is correct |
25 |
Correct |
28 ms |
7936 KB |
Output is correct |
26 |
Correct |
30 ms |
7936 KB |
Output is correct |
27 |
Correct |
19 ms |
8192 KB |
Output is correct |
28 |
Correct |
17 ms |
8196 KB |
Output is correct |
29 |
Correct |
22 ms |
8252 KB |
Output is correct |
30 |
Correct |
64 ms |
8440 KB |
Output is correct |
31 |
Correct |
60 ms |
8440 KB |
Output is correct |
32 |
Correct |
61 ms |
8340 KB |
Output is correct |
33 |
Correct |
82 ms |
12672 KB |
Output is correct |
34 |
Correct |
82 ms |
12784 KB |
Output is correct |
35 |
Correct |
130 ms |
12648 KB |
Output is correct |
36 |
Correct |
630 ms |
15480 KB |
Output is correct |
37 |
Correct |
712 ms |
15540 KB |
Output is correct |
38 |
Correct |
692 ms |
15440 KB |
Output is correct |
39 |
Correct |
639 ms |
25376 KB |
Output is correct |
40 |
Correct |
686 ms |
25876 KB |
Output is correct |
41 |
Correct |
735 ms |
25216 KB |
Output is correct |
42 |
Correct |
327 ms |
15472 KB |
Output is correct |
43 |
Correct |
536 ms |
15364 KB |
Output is correct |
44 |
Correct |
472 ms |
15472 KB |
Output is correct |
45 |
Correct |
478 ms |
15368 KB |
Output is correct |
46 |
Correct |
503 ms |
15448 KB |
Output is correct |
47 |
Correct |
472 ms |
15472 KB |
Output is correct |
48 |
Correct |
599 ms |
15472 KB |
Output is correct |
49 |
Correct |
444 ms |
15472 KB |
Output is correct |
50 |
Correct |
496 ms |
15472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
9 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
9 ms |
7424 KB |
Output is correct |
6 |
Correct |
10 ms |
7424 KB |
Output is correct |
7 |
Correct |
9 ms |
7424 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
9 ms |
7424 KB |
Output is correct |
10 |
Correct |
8 ms |
7424 KB |
Output is correct |
11 |
Correct |
8 ms |
7424 KB |
Output is correct |
12 |
Correct |
9 ms |
7424 KB |
Output is correct |
13 |
Correct |
9 ms |
7424 KB |
Output is correct |
14 |
Correct |
10 ms |
7424 KB |
Output is correct |
15 |
Correct |
13 ms |
7424 KB |
Output is correct |
16 |
Correct |
9 ms |
7424 KB |
Output is correct |
17 |
Correct |
13 ms |
7552 KB |
Output is correct |
18 |
Correct |
10 ms |
7424 KB |
Output is correct |
19 |
Correct |
13 ms |
7808 KB |
Output is correct |
20 |
Correct |
16 ms |
7808 KB |
Output is correct |
21 |
Correct |
14 ms |
7808 KB |
Output is correct |
22 |
Correct |
31 ms |
7928 KB |
Output is correct |
23 |
Correct |
44 ms |
7936 KB |
Output is correct |
24 |
Correct |
32 ms |
7936 KB |
Output is correct |
25 |
Correct |
28 ms |
7936 KB |
Output is correct |
26 |
Correct |
30 ms |
7936 KB |
Output is correct |
27 |
Correct |
265 ms |
24800 KB |
Output is correct |
28 |
Correct |
273 ms |
23648 KB |
Output is correct |
29 |
Correct |
265 ms |
23392 KB |
Output is correct |
30 |
Correct |
263 ms |
24720 KB |
Output is correct |
31 |
Correct |
453 ms |
24412 KB |
Output is correct |
32 |
Correct |
1087 ms |
28272 KB |
Output is correct |
33 |
Correct |
598 ms |
24928 KB |
Output is correct |
34 |
Correct |
679 ms |
25572 KB |
Output is correct |
35 |
Correct |
9 ms |
7424 KB |
Output is correct |
36 |
Correct |
696 ms |
15708 KB |
Output is correct |
37 |
Correct |
2591 ms |
32068 KB |
Output is correct |
38 |
Correct |
2655 ms |
32224 KB |
Output is correct |
39 |
Correct |
2443 ms |
31212 KB |
Output is correct |
40 |
Correct |
887 ms |
19816 KB |
Output is correct |
41 |
Correct |
379 ms |
13936 KB |
Output is correct |
42 |
Correct |
66 ms |
8952 KB |
Output is correct |
43 |
Correct |
2725 ms |
32148 KB |
Output is correct |
44 |
Correct |
2079 ms |
38624 KB |
Output is correct |
45 |
Correct |
2083 ms |
31980 KB |
Output is correct |
46 |
Correct |
1506 ms |
32220 KB |
Output is correct |
47 |
Correct |
692 ms |
25920 KB |
Output is correct |
48 |
Correct |
1586 ms |
32240 KB |
Output is correct |
49 |
Correct |
1647 ms |
32096 KB |
Output is correct |
50 |
Correct |
482 ms |
24288 KB |
Output is correct |
51 |
Correct |
19 ms |
8192 KB |
Output is correct |
52 |
Correct |
17 ms |
8196 KB |
Output is correct |
53 |
Correct |
22 ms |
8252 KB |
Output is correct |
54 |
Correct |
64 ms |
8440 KB |
Output is correct |
55 |
Correct |
60 ms |
8440 KB |
Output is correct |
56 |
Correct |
61 ms |
8340 KB |
Output is correct |
57 |
Correct |
82 ms |
12672 KB |
Output is correct |
58 |
Correct |
82 ms |
12784 KB |
Output is correct |
59 |
Correct |
130 ms |
12648 KB |
Output is correct |
60 |
Correct |
630 ms |
15480 KB |
Output is correct |
61 |
Correct |
712 ms |
15540 KB |
Output is correct |
62 |
Correct |
692 ms |
15440 KB |
Output is correct |
63 |
Correct |
639 ms |
25376 KB |
Output is correct |
64 |
Correct |
686 ms |
25876 KB |
Output is correct |
65 |
Correct |
735 ms |
25216 KB |
Output is correct |
66 |
Correct |
327 ms |
15472 KB |
Output is correct |
67 |
Correct |
536 ms |
15364 KB |
Output is correct |
68 |
Correct |
472 ms |
15472 KB |
Output is correct |
69 |
Correct |
478 ms |
15368 KB |
Output is correct |
70 |
Correct |
503 ms |
15448 KB |
Output is correct |
71 |
Correct |
472 ms |
15472 KB |
Output is correct |
72 |
Correct |
599 ms |
15472 KB |
Output is correct |
73 |
Correct |
444 ms |
15472 KB |
Output is correct |
74 |
Correct |
496 ms |
15472 KB |
Output is correct |
75 |
Correct |
322 ms |
30316 KB |
Output is correct |
76 |
Correct |
299 ms |
31556 KB |
Output is correct |
77 |
Correct |
267 ms |
31200 KB |
Output is correct |
78 |
Correct |
256 ms |
30588 KB |
Output is correct |
79 |
Correct |
375 ms |
31448 KB |
Output is correct |
80 |
Correct |
291 ms |
31816 KB |
Output is correct |
81 |
Correct |
2462 ms |
39168 KB |
Output is correct |
82 |
Correct |
2344 ms |
39264 KB |
Output is correct |
83 |
Correct |
2310 ms |
39364 KB |
Output is correct |
84 |
Correct |
2522 ms |
39288 KB |
Output is correct |
85 |
Correct |
2509 ms |
39284 KB |
Output is correct |
86 |
Correct |
2549 ms |
39384 KB |
Output is correct |
87 |
Correct |
2891 ms |
39104 KB |
Output is correct |
88 |
Correct |
2404 ms |
61980 KB |
Output is correct |
89 |
Correct |
2186 ms |
70116 KB |
Output is correct |
90 |
Correct |
2362 ms |
70168 KB |
Output is correct |
91 |
Correct |
2168 ms |
66940 KB |
Output is correct |
92 |
Correct |
2395 ms |
61952 KB |
Output is correct |
93 |
Correct |
1863 ms |
38608 KB |
Output is correct |
94 |
Correct |
1942 ms |
39012 KB |
Output is correct |
95 |
Correct |
1714 ms |
38624 KB |
Output is correct |
96 |
Correct |
1779 ms |
38736 KB |
Output is correct |
97 |
Correct |
2757 ms |
38564 KB |
Output is correct |
98 |
Correct |
1220 ms |
36192 KB |
Output is correct |
99 |
Correct |
1965 ms |
38900 KB |
Output is correct |
100 |
Correct |
1745 ms |
38444 KB |
Output is correct |
101 |
Correct |
1510 ms |
37476 KB |
Output is correct |
102 |
Correct |
1924 ms |
38584 KB |
Output is correct |
103 |
Correct |
2693 ms |
38600 KB |
Output is correct |
104 |
Correct |
1975 ms |
38440 KB |
Output is correct |
105 |
Correct |
1169 ms |
36364 KB |
Output is correct |
106 |
Correct |
1537 ms |
38576 KB |
Output is correct |
107 |
Correct |
1496 ms |
38500 KB |
Output is correct |
108 |
Correct |
1587 ms |
38684 KB |
Output is correct |
109 |
Correct |
1588 ms |
38396 KB |
Output is correct |
110 |
Correct |
1391 ms |
38392 KB |
Output is correct |
111 |
Correct |
1333 ms |
38240 KB |
Output is correct |
112 |
Correct |
1445 ms |
38320 KB |
Output is correct |
113 |
Correct |
1474 ms |
38240 KB |
Output is correct |
114 |
Correct |
1588 ms |
38244 KB |
Output is correct |
115 |
Correct |
1474 ms |
38084 KB |
Output is correct |
116 |
Correct |
1530 ms |
38084 KB |
Output is correct |