#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
struct circle{
int x, y, r, id;
bool operator<(const circle& a)const{
return x < a.x || (x == a.x && id < a.id);
}
};
int dist(circle& a, circle& b){
int x = a.x - b.x;
int y = a.y - b.y;
return x * x + y * y;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<circle> X;
vector<circle> data;
int n;
cin >> n;
vector<int> ans(n, -1);
for(int i = 0; i < n; i++){
int x, y, r;
cin >> x >> y >> r;
X.pb({x, y, r, i});
data.pb({x, y, r, i});
}
sort(all(data), [&](circle a, circle b){return a.r > b.r || (a.r == b.r && a.id < b.id);});
for(auto c : data){
if(ans[c.id] >= 0) continue;
for(auto p : X){
if(ans[p.id] >= 0) continue;
if(dist(c, p) <= (c.r + p.r) * (c.r + p.r)){
ans[p.id] = c.id;
}
}
}
for(int i = 0; i < n; i++){
cout << ans[i] + 1 << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
8 ms |
1148 KB |
Output is correct |
20 |
Correct |
9 ms |
1180 KB |
Output is correct |
21 |
Correct |
9 ms |
1148 KB |
Output is correct |
22 |
Correct |
97 ms |
1024 KB |
Output is correct |
23 |
Correct |
98 ms |
1024 KB |
Output is correct |
24 |
Correct |
97 ms |
1012 KB |
Output is correct |
25 |
Correct |
96 ms |
1024 KB |
Output is correct |
26 |
Correct |
99 ms |
1140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
204 ms |
27568 KB |
Output is correct |
2 |
Correct |
207 ms |
33720 KB |
Output is correct |
3 |
Correct |
201 ms |
33592 KB |
Output is correct |
4 |
Correct |
200 ms |
33720 KB |
Output is correct |
5 |
Execution timed out |
3083 ms |
31804 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
3086 ms |
10452 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3076 ms |
27568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
8 ms |
1148 KB |
Output is correct |
20 |
Correct |
9 ms |
1180 KB |
Output is correct |
21 |
Correct |
9 ms |
1148 KB |
Output is correct |
22 |
Correct |
97 ms |
1024 KB |
Output is correct |
23 |
Correct |
98 ms |
1024 KB |
Output is correct |
24 |
Correct |
97 ms |
1012 KB |
Output is correct |
25 |
Correct |
96 ms |
1024 KB |
Output is correct |
26 |
Correct |
99 ms |
1140 KB |
Output is correct |
27 |
Correct |
12 ms |
1708 KB |
Output is correct |
28 |
Correct |
14 ms |
1704 KB |
Output is correct |
29 |
Correct |
11 ms |
1708 KB |
Output is correct |
30 |
Correct |
398 ms |
1580 KB |
Output is correct |
31 |
Correct |
432 ms |
1580 KB |
Output is correct |
32 |
Correct |
398 ms |
1580 KB |
Output is correct |
33 |
Correct |
83 ms |
11480 KB |
Output is correct |
34 |
Correct |
89 ms |
11336 KB |
Output is correct |
35 |
Correct |
84 ms |
11216 KB |
Output is correct |
36 |
Execution timed out |
3087 ms |
10196 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
8 ms |
1148 KB |
Output is correct |
20 |
Correct |
9 ms |
1180 KB |
Output is correct |
21 |
Correct |
9 ms |
1148 KB |
Output is correct |
22 |
Correct |
97 ms |
1024 KB |
Output is correct |
23 |
Correct |
98 ms |
1024 KB |
Output is correct |
24 |
Correct |
97 ms |
1012 KB |
Output is correct |
25 |
Correct |
96 ms |
1024 KB |
Output is correct |
26 |
Correct |
99 ms |
1140 KB |
Output is correct |
27 |
Correct |
204 ms |
27568 KB |
Output is correct |
28 |
Correct |
207 ms |
33720 KB |
Output is correct |
29 |
Correct |
201 ms |
33592 KB |
Output is correct |
30 |
Correct |
200 ms |
33720 KB |
Output is correct |
31 |
Execution timed out |
3083 ms |
31804 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |