#pragma GCC optimize( "O3" )
#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 5;
const int C = 1000000000;
template < typename A, typename B >
using UMP = unordered_map< A, B >;
using lld = int64_t;
int n;
vector< int > ord;
lld x[ N ], y[ N ], r[ N ];
inline bool inter( int i, int j ) {
const lld ox = x[ i ] - x[ j ];
const lld oy = y[ i ] - y[ j ];
const lld R = r[ i ] + r[ j ];
return ox * ox + oy * oy <= R * R;
}
void init() {
cin >> n;
for ( int i = 0 ; i < n ; ++ i )
cin >> x[ i ] >> y[ i ] >> r[ i ];
for ( int i = 0 ; i < n ; ++ i )
x[ i ] += C, y[ i ] += C;
ord.resize( n );
iota( ord.begin(), ord.end(), 0 );
sort( ord.begin(), ord.end(), []( int a, int b ) {
return tie( r[ a ], b ) > tie( r[ b ], a );
} );
}
UMP< lld, UMP< lld, vector< int > > > plane;
int ans[ N ];
int LogL = 32;
lld unit = 1;
inline void build() {
plane.clear(); plane.rehash( n );
for ( int i = 0 ; i < n ; ++ i ) {
if ( ans[ i ] ) continue;
plane[ x[ i ] >> LogL ][ y[ i ] >> LogL ].push_back( i );
}
}
const int dx[] = { -1, 0, 1 }, dy[] = { -1, 0, 1 };
void solve() {
build();
for ( int i : ord ) {
if ( ans[ i ] ) continue;
ans[ i ] = i + 1;
int pLogL = LogL;
while( ( unit << ( -- LogL ) ) > r[ i ] + r[ i ] );
if ( pLogL != ++ LogL ) build();
lld X = x[ i ] >> LogL, Y = y[ i ] >> LogL;
for ( int i_ = 0 ; i_ < 3 ; ++ i_ ) {
for ( int j_ = 0 ; j_ < 3 ; ++ j_ ) {
for ( int j : plane[ X + dx[ i_ ] ][ Y + dy[ j_ ] ] ) {
if ( ans[ j ] ) continue;
if ( inter( i, j ) ) ans[ j ] = i + 1;
}
}
}
}
for ( int i = 0 ; i < n ; ++ i )
cout << ans[ i ] << " \n"[ i == n - 1 ];
}
int main() {
ios_base::sync_with_stdio( false );
cin.tie( nullptr );
init(); solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
716 KB |
Output is correct |
20 |
Correct |
3 ms |
716 KB |
Output is correct |
21 |
Correct |
3 ms |
716 KB |
Output is correct |
22 |
Correct |
10 ms |
2252 KB |
Output is correct |
23 |
Correct |
14 ms |
2168 KB |
Output is correct |
24 |
Correct |
10 ms |
2252 KB |
Output is correct |
25 |
Correct |
12 ms |
3416 KB |
Output is correct |
26 |
Correct |
9 ms |
2596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
22936 KB |
Output is correct |
2 |
Correct |
174 ms |
23584 KB |
Output is correct |
3 |
Correct |
148 ms |
23776 KB |
Output is correct |
4 |
Correct |
158 ms |
22216 KB |
Output is correct |
5 |
Correct |
177 ms |
21220 KB |
Output is correct |
6 |
Correct |
535 ms |
43412 KB |
Output is correct |
7 |
Correct |
209 ms |
22400 KB |
Output is correct |
8 |
Correct |
234 ms |
26656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
561 ms |
33512 KB |
Output is correct |
3 |
Correct |
2209 ms |
99576 KB |
Output is correct |
4 |
Correct |
2081 ms |
96848 KB |
Output is correct |
5 |
Correct |
1660 ms |
73732 KB |
Output is correct |
6 |
Correct |
576 ms |
35400 KB |
Output is correct |
7 |
Correct |
222 ms |
24488 KB |
Output is correct |
8 |
Correct |
23 ms |
5492 KB |
Output is correct |
9 |
Correct |
2287 ms |
89580 KB |
Output is correct |
10 |
Correct |
1247 ms |
67848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1697 ms |
189032 KB |
Output is correct |
2 |
Correct |
1057 ms |
330812 KB |
Output is correct |
3 |
Correct |
219 ms |
25760 KB |
Output is correct |
4 |
Correct |
909 ms |
254848 KB |
Output is correct |
5 |
Correct |
1055 ms |
303000 KB |
Output is correct |
6 |
Correct |
175 ms |
24412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
716 KB |
Output is correct |
20 |
Correct |
3 ms |
716 KB |
Output is correct |
21 |
Correct |
3 ms |
716 KB |
Output is correct |
22 |
Correct |
10 ms |
2252 KB |
Output is correct |
23 |
Correct |
14 ms |
2168 KB |
Output is correct |
24 |
Correct |
10 ms |
2252 KB |
Output is correct |
25 |
Correct |
12 ms |
3416 KB |
Output is correct |
26 |
Correct |
9 ms |
2596 KB |
Output is correct |
27 |
Correct |
6 ms |
1180 KB |
Output is correct |
28 |
Correct |
8 ms |
1100 KB |
Output is correct |
29 |
Correct |
6 ms |
1100 KB |
Output is correct |
30 |
Correct |
23 ms |
4292 KB |
Output is correct |
31 |
Correct |
23 ms |
4556 KB |
Output is correct |
32 |
Correct |
24 ms |
4020 KB |
Output is correct |
33 |
Correct |
52 ms |
8892 KB |
Output is correct |
34 |
Correct |
52 ms |
8892 KB |
Output is correct |
35 |
Correct |
53 ms |
7996 KB |
Output is correct |
36 |
Correct |
565 ms |
38432 KB |
Output is correct |
37 |
Correct |
537 ms |
35120 KB |
Output is correct |
38 |
Correct |
645 ms |
37792 KB |
Output is correct |
39 |
Correct |
169 ms |
8188 KB |
Output is correct |
40 |
Correct |
152 ms |
8152 KB |
Output is correct |
41 |
Correct |
142 ms |
8200 KB |
Output is correct |
42 |
Correct |
67 ms |
8504 KB |
Output is correct |
43 |
Correct |
293 ms |
94836 KB |
Output is correct |
44 |
Correct |
301 ms |
95048 KB |
Output is correct |
45 |
Correct |
297 ms |
95016 KB |
Output is correct |
46 |
Correct |
300 ms |
95040 KB |
Output is correct |
47 |
Correct |
305 ms |
95148 KB |
Output is correct |
48 |
Correct |
295 ms |
95036 KB |
Output is correct |
49 |
Correct |
306 ms |
95200 KB |
Output is correct |
50 |
Correct |
293 ms |
95076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
716 KB |
Output is correct |
20 |
Correct |
3 ms |
716 KB |
Output is correct |
21 |
Correct |
3 ms |
716 KB |
Output is correct |
22 |
Correct |
10 ms |
2252 KB |
Output is correct |
23 |
Correct |
14 ms |
2168 KB |
Output is correct |
24 |
Correct |
10 ms |
2252 KB |
Output is correct |
25 |
Correct |
12 ms |
3416 KB |
Output is correct |
26 |
Correct |
9 ms |
2596 KB |
Output is correct |
27 |
Correct |
155 ms |
22936 KB |
Output is correct |
28 |
Correct |
174 ms |
23584 KB |
Output is correct |
29 |
Correct |
148 ms |
23776 KB |
Output is correct |
30 |
Correct |
158 ms |
22216 KB |
Output is correct |
31 |
Correct |
177 ms |
21220 KB |
Output is correct |
32 |
Correct |
535 ms |
43412 KB |
Output is correct |
33 |
Correct |
209 ms |
22400 KB |
Output is correct |
34 |
Correct |
234 ms |
26656 KB |
Output is correct |
35 |
Correct |
1 ms |
332 KB |
Output is correct |
36 |
Correct |
561 ms |
33512 KB |
Output is correct |
37 |
Correct |
2209 ms |
99576 KB |
Output is correct |
38 |
Correct |
2081 ms |
96848 KB |
Output is correct |
39 |
Correct |
1660 ms |
73732 KB |
Output is correct |
40 |
Correct |
576 ms |
35400 KB |
Output is correct |
41 |
Correct |
222 ms |
24488 KB |
Output is correct |
42 |
Correct |
23 ms |
5492 KB |
Output is correct |
43 |
Correct |
2287 ms |
89580 KB |
Output is correct |
44 |
Correct |
1247 ms |
67848 KB |
Output is correct |
45 |
Correct |
1697 ms |
189032 KB |
Output is correct |
46 |
Correct |
1057 ms |
330812 KB |
Output is correct |
47 |
Correct |
219 ms |
25760 KB |
Output is correct |
48 |
Correct |
909 ms |
254848 KB |
Output is correct |
49 |
Correct |
1055 ms |
303000 KB |
Output is correct |
50 |
Correct |
175 ms |
24412 KB |
Output is correct |
51 |
Correct |
6 ms |
1180 KB |
Output is correct |
52 |
Correct |
8 ms |
1100 KB |
Output is correct |
53 |
Correct |
6 ms |
1100 KB |
Output is correct |
54 |
Correct |
23 ms |
4292 KB |
Output is correct |
55 |
Correct |
23 ms |
4556 KB |
Output is correct |
56 |
Correct |
24 ms |
4020 KB |
Output is correct |
57 |
Correct |
52 ms |
8892 KB |
Output is correct |
58 |
Correct |
52 ms |
8892 KB |
Output is correct |
59 |
Correct |
53 ms |
7996 KB |
Output is correct |
60 |
Correct |
565 ms |
38432 KB |
Output is correct |
61 |
Correct |
537 ms |
35120 KB |
Output is correct |
62 |
Correct |
645 ms |
37792 KB |
Output is correct |
63 |
Correct |
169 ms |
8188 KB |
Output is correct |
64 |
Correct |
152 ms |
8152 KB |
Output is correct |
65 |
Correct |
142 ms |
8200 KB |
Output is correct |
66 |
Correct |
67 ms |
8504 KB |
Output is correct |
67 |
Correct |
293 ms |
94836 KB |
Output is correct |
68 |
Correct |
301 ms |
95048 KB |
Output is correct |
69 |
Correct |
297 ms |
95016 KB |
Output is correct |
70 |
Correct |
300 ms |
95040 KB |
Output is correct |
71 |
Correct |
305 ms |
95148 KB |
Output is correct |
72 |
Correct |
295 ms |
95036 KB |
Output is correct |
73 |
Correct |
306 ms |
95200 KB |
Output is correct |
74 |
Correct |
293 ms |
95076 KB |
Output is correct |
75 |
Correct |
169 ms |
24720 KB |
Output is correct |
76 |
Correct |
180 ms |
24996 KB |
Output is correct |
77 |
Correct |
176 ms |
25080 KB |
Output is correct |
78 |
Correct |
157 ms |
26204 KB |
Output is correct |
79 |
Correct |
213 ms |
25132 KB |
Output is correct |
80 |
Correct |
157 ms |
26216 KB |
Output is correct |
81 |
Correct |
2174 ms |
114936 KB |
Output is correct |
82 |
Correct |
1840 ms |
116376 KB |
Output is correct |
83 |
Correct |
2040 ms |
97524 KB |
Output is correct |
84 |
Correct |
1925 ms |
94296 KB |
Output is correct |
85 |
Correct |
2089 ms |
102828 KB |
Output is correct |
86 |
Correct |
1986 ms |
114724 KB |
Output is correct |
87 |
Correct |
1806 ms |
86108 KB |
Output is correct |
88 |
Correct |
575 ms |
24124 KB |
Output is correct |
89 |
Correct |
586 ms |
24136 KB |
Output is correct |
90 |
Correct |
584 ms |
24284 KB |
Output is correct |
91 |
Correct |
580 ms |
24256 KB |
Output is correct |
92 |
Correct |
565 ms |
24080 KB |
Output is correct |
93 |
Correct |
1838 ms |
163132 KB |
Output is correct |
94 |
Correct |
1768 ms |
110540 KB |
Output is correct |
95 |
Correct |
1819 ms |
179264 KB |
Output is correct |
96 |
Correct |
1936 ms |
193720 KB |
Output is correct |
97 |
Correct |
1691 ms |
110064 KB |
Output is correct |
98 |
Correct |
657 ms |
48288 KB |
Output is correct |
99 |
Correct |
1706 ms |
177080 KB |
Output is correct |
100 |
Correct |
1603 ms |
195976 KB |
Output is correct |
101 |
Correct |
825 ms |
47020 KB |
Output is correct |
102 |
Correct |
1552 ms |
167608 KB |
Output is correct |
103 |
Correct |
1664 ms |
102880 KB |
Output is correct |
104 |
Correct |
1637 ms |
201356 KB |
Output is correct |
105 |
Correct |
282 ms |
24768 KB |
Output is correct |
106 |
Correct |
669 ms |
161684 KB |
Output is correct |
107 |
Correct |
743 ms |
162016 KB |
Output is correct |
108 |
Correct |
681 ms |
161588 KB |
Output is correct |
109 |
Correct |
667 ms |
161440 KB |
Output is correct |
110 |
Correct |
670 ms |
161232 KB |
Output is correct |
111 |
Correct |
676 ms |
161668 KB |
Output is correct |
112 |
Correct |
676 ms |
161504 KB |
Output is correct |
113 |
Correct |
665 ms |
161024 KB |
Output is correct |
114 |
Correct |
672 ms |
161160 KB |
Output is correct |
115 |
Correct |
676 ms |
161768 KB |
Output is correct |
116 |
Correct |
737 ms |
221008 KB |
Output is correct |