#include <bits/stdc++.h>
#define N 1000005
#define ff first
#define ss second
#define ll long long
const ll MAXN = 1e9;
using namespace std;
ll n;
ll x[N], y[N], r[N], ans[N];
ll dist(int i1, int i2){
return (x[i1] - x[i2]) * (x[i1] - x[i2]) + (y[i1] - y[i2]) * (y[i1] - y[i2]);
}
void solvesubtask1(){
set<pair<ll, ll> > s;
for(int i = 1; i <= n; i++){
s.insert({-r[i], i});
}
while(s.size()){
int k = s.begin() -> ss;
for(int i = 1; i <= n; i++){
if(ans[i] == 0){
if(dist(i, k) <= ((r[i] + r[k]) * (r[i] + r[k]))){
ans[i] = k;
s.erase({-r[i], i});
}
}
}
}
for(int i = 1; i <= n; i++){
cout << ans[i] << ' ';
}
}
int main(){
ios_base::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];
}
if(n <= 5000){
solvesubtask1();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
472 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
980 KB |
Output is correct |
20 |
Correct |
5 ms |
988 KB |
Output is correct |
21 |
Correct |
4 ms |
980 KB |
Output is correct |
22 |
Correct |
95 ms |
936 KB |
Output is correct |
23 |
Correct |
105 ms |
952 KB |
Output is correct |
24 |
Correct |
86 ms |
948 KB |
Output is correct |
25 |
Correct |
88 ms |
940 KB |
Output is correct |
26 |
Correct |
85 ms |
940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
75 ms |
14008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
44 ms |
5332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
90 ms |
15228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
472 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
980 KB |
Output is correct |
20 |
Correct |
5 ms |
988 KB |
Output is correct |
21 |
Correct |
4 ms |
980 KB |
Output is correct |
22 |
Correct |
95 ms |
936 KB |
Output is correct |
23 |
Correct |
105 ms |
952 KB |
Output is correct |
24 |
Correct |
86 ms |
948 KB |
Output is correct |
25 |
Correct |
88 ms |
940 KB |
Output is correct |
26 |
Correct |
85 ms |
940 KB |
Output is correct |
27 |
Incorrect |
5 ms |
880 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
472 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
980 KB |
Output is correct |
20 |
Correct |
5 ms |
988 KB |
Output is correct |
21 |
Correct |
4 ms |
980 KB |
Output is correct |
22 |
Correct |
95 ms |
936 KB |
Output is correct |
23 |
Correct |
105 ms |
952 KB |
Output is correct |
24 |
Correct |
86 ms |
948 KB |
Output is correct |
25 |
Correct |
88 ms |
940 KB |
Output is correct |
26 |
Correct |
85 ms |
940 KB |
Output is correct |
27 |
Incorrect |
75 ms |
14008 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |