#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> adj[5001];
pair<int,pair<int,int>> circles[5001];
int ans[5001];
bool check(int a,int b){
return (circles[a].first+circles[b].first)*(circles[a].first+circles[b].first)>=(circles[a].second.first-circles[b].second.first)*(circles[a].second.first-circles[b].second.first)+(circles[a].second.second-circles[b].second.second)*(circles[a].second.second-circles[b].second.second);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for(int i=1;i<=n;i++)cin>>circles[i].second.first>>circles[i].second.second>>circles[i].first;
set<pair<int,int>> circle;
for(int i=1;i<=n;i++){
circle.insert({circles[i].first,-i});
adj[i].emplace_back(i);
for(int j=1;j<=n;j++){
if(check(i,j))adj[i].emplace_back(j);
}
}
auto remove = [&](int x,int p){
if(circle.count({circles[x].first,-x})) {
circle.erase({circles[x].first, -x});
ans[x] = p;
}
};
while(!circle.empty()){
auto curr = *--circle.end();curr.second=-curr.second;
for(int&i:adj[curr.second]){
remove(i,curr.second);
}
}
for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
12 ms |
8024 KB |
Output is correct |
17 |
Correct |
12 ms |
7516 KB |
Output is correct |
18 |
Correct |
9 ms |
8624 KB |
Output is correct |
19 |
Correct |
209 ms |
211632 KB |
Output is correct |
20 |
Correct |
181 ms |
217296 KB |
Output is correct |
21 |
Correct |
250 ms |
137812 KB |
Output is correct |
22 |
Correct |
58 ms |
1232 KB |
Output is correct |
23 |
Correct |
66 ms |
1204 KB |
Output is correct |
24 |
Correct |
63 ms |
1492 KB |
Output is correct |
25 |
Correct |
58 ms |
1284 KB |
Output is correct |
26 |
Correct |
58 ms |
1104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
3 ms |
1372 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
1372 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
12 ms |
8024 KB |
Output is correct |
17 |
Correct |
12 ms |
7516 KB |
Output is correct |
18 |
Correct |
9 ms |
8624 KB |
Output is correct |
19 |
Correct |
209 ms |
211632 KB |
Output is correct |
20 |
Correct |
181 ms |
217296 KB |
Output is correct |
21 |
Correct |
250 ms |
137812 KB |
Output is correct |
22 |
Correct |
58 ms |
1232 KB |
Output is correct |
23 |
Correct |
66 ms |
1204 KB |
Output is correct |
24 |
Correct |
63 ms |
1492 KB |
Output is correct |
25 |
Correct |
58 ms |
1284 KB |
Output is correct |
26 |
Correct |
58 ms |
1104 KB |
Output is correct |
27 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
12 ms |
8024 KB |
Output is correct |
17 |
Correct |
12 ms |
7516 KB |
Output is correct |
18 |
Correct |
9 ms |
8624 KB |
Output is correct |
19 |
Correct |
209 ms |
211632 KB |
Output is correct |
20 |
Correct |
181 ms |
217296 KB |
Output is correct |
21 |
Correct |
250 ms |
137812 KB |
Output is correct |
22 |
Correct |
58 ms |
1232 KB |
Output is correct |
23 |
Correct |
66 ms |
1204 KB |
Output is correct |
24 |
Correct |
63 ms |
1492 KB |
Output is correct |
25 |
Correct |
58 ms |
1284 KB |
Output is correct |
26 |
Correct |
58 ms |
1104 KB |
Output is correct |
27 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |