#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define vi vector<int>
typedef tuple<int,int,int> iii;
typedef tuple<int,int,int,int> iiii;
typedef vector<ii> vii;
struct Comp{
bool operator()(const iiii a, const iiii b){
if (get<2>(a)!=get<2>(b)) return get<2>(a) < get<2>(b); else return get<3>(a) > get<3>(b);
}
};
int32_t main(){
int n,x,y,r,idx; cin>>n;
vector<iiii> V;
vi AL[n];
for (int i=0; i<n; i++){
cin>>x>>y>>r;
V.emplace_back(iiii({x,y,r,i}));
}
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
if ((get<0>(V[i])-get<0>(V[j]))*(get<0>(V[i])-get<0>(V[j]))
+ (get<1>(V[i])-get<1>(V[j]))*(get<1>(V[i])-get<1>(V[j]))
<= (get<2>(V[i])+get<2>(V[j]))*(get<2>(V[i])+get<2>(V[j]))){
AL[i].emplace_back(j);
AL[j].emplace_back(i);
}
}
}
priority_queue<iiii, vector<iiii>, Comp> PQ;
for (int i=0; i<n; i++){
PQ.push(V[i]);
}
bool vis[n]={};
int ans[n];
while (!PQ.empty()){
iiii curr=PQ.top(); PQ.pop();
idx = get<3>(curr);
if (vis[idx]) continue;
ans[idx]=idx;
for (auto nb : AL[idx]){
if (!vis[nb]){
vis[nb]=true;
ans[nb]=idx;
}
}
}
for (int i=0; i<n; i++) cout<<ans[i]+1<<" ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
8992 KB |
Output is correct |
17 |
Correct |
9 ms |
8540 KB |
Output is correct |
18 |
Correct |
9 ms |
9236 KB |
Output is correct |
19 |
Correct |
249 ms |
254696 KB |
Output is correct |
20 |
Correct |
232 ms |
256040 KB |
Output is correct |
21 |
Correct |
200 ms |
158668 KB |
Output is correct |
22 |
Correct |
31 ms |
1212 KB |
Output is correct |
23 |
Correct |
26 ms |
1240 KB |
Output is correct |
24 |
Correct |
27 ms |
1224 KB |
Output is correct |
25 |
Correct |
26 ms |
1116 KB |
Output is correct |
26 |
Correct |
26 ms |
1104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2292 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
3082 ms |
11008 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3104 ms |
31224 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
8992 KB |
Output is correct |
17 |
Correct |
9 ms |
8540 KB |
Output is correct |
18 |
Correct |
9 ms |
9236 KB |
Output is correct |
19 |
Correct |
249 ms |
254696 KB |
Output is correct |
20 |
Correct |
232 ms |
256040 KB |
Output is correct |
21 |
Correct |
200 ms |
158668 KB |
Output is correct |
22 |
Correct |
31 ms |
1212 KB |
Output is correct |
23 |
Correct |
26 ms |
1240 KB |
Output is correct |
24 |
Correct |
27 ms |
1224 KB |
Output is correct |
25 |
Correct |
26 ms |
1116 KB |
Output is correct |
26 |
Correct |
26 ms |
1104 KB |
Output is correct |
27 |
Correct |
941 ms |
741212 KB |
Output is correct |
28 |
Correct |
1051 ms |
926560 KB |
Output is correct |
29 |
Correct |
1050 ms |
890396 KB |
Output is correct |
30 |
Correct |
91 ms |
1992 KB |
Output is correct |
31 |
Correct |
91 ms |
1880 KB |
Output is correct |
32 |
Correct |
123 ms |
1892 KB |
Output is correct |
33 |
Runtime error |
1573 ms |
1048576 KB |
Execution killed with signal 9 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
8992 KB |
Output is correct |
17 |
Correct |
9 ms |
8540 KB |
Output is correct |
18 |
Correct |
9 ms |
9236 KB |
Output is correct |
19 |
Correct |
249 ms |
254696 KB |
Output is correct |
20 |
Correct |
232 ms |
256040 KB |
Output is correct |
21 |
Correct |
200 ms |
158668 KB |
Output is correct |
22 |
Correct |
31 ms |
1212 KB |
Output is correct |
23 |
Correct |
26 ms |
1240 KB |
Output is correct |
24 |
Correct |
27 ms |
1224 KB |
Output is correct |
25 |
Correct |
26 ms |
1116 KB |
Output is correct |
26 |
Correct |
26 ms |
1104 KB |
Output is correct |
27 |
Runtime error |
2292 ms |
1048576 KB |
Execution killed with signal 9 |
28 |
Halted |
0 ms |
0 KB |
- |