#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
#define f first
#define s second
#define pb push_back
#define all(x) begin(x), end(x)
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct hashFunc{
size_t operator()(const pl& a)const {
return a.f ^(a.s+1);
}
};
const int mx = 300005;
int n;
ll x[mx];
ll y[mx];
ll r[mx];
bool present[mx];
int ans[mx];
bool circleIntersect(int a, int b){
ll dist = (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
if(dist <= (r[a]+r[b])*(r[a]+r[b])) return 1;
return 0;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
//gp_hash_table<pl, vi, hashFunc> g;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> r[i];
}
vector<pair<ll, int>> v;
for(int i = 1; i <= n; i++){
v.pb(mp(-r[i], i));
}
sort(all(v));
vi inds;
for(int i = 0; i < n; i++){
inds.pb(v[i].s);
}
for(int i = 1; i <= n; i++){
present[i] = 1;
}
for(auto ind: inds){
if(present[ind]){
present[ind] = 0;
ans[ind] = ind;
for(int i = 1; i <= n; i++){
if(present[i] && circleIntersect(i, ind)){
present[i] = 0;
ans[i] = ind;
}
}
}
}
for(int i = 1; i <= n; i++){
cout << ans[i] << " ";
}
cout << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 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 |
2 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 |
800 KB |
Output is correct |
20 |
Correct |
4 ms |
844 KB |
Output is correct |
21 |
Correct |
5 ms |
844 KB |
Output is correct |
22 |
Correct |
127 ms |
816 KB |
Output is correct |
23 |
Correct |
127 ms |
812 KB |
Output is correct |
24 |
Correct |
130 ms |
820 KB |
Output is correct |
25 |
Correct |
140 ms |
820 KB |
Output is correct |
26 |
Correct |
127 ms |
828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
25544 KB |
Output is correct |
2 |
Correct |
175 ms |
25412 KB |
Output is correct |
3 |
Correct |
172 ms |
25172 KB |
Output is correct |
4 |
Correct |
166 ms |
25500 KB |
Output is correct |
5 |
Execution timed out |
3068 ms |
21284 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Execution timed out |
3066 ms |
8532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3063 ms |
23544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 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 |
2 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 |
800 KB |
Output is correct |
20 |
Correct |
4 ms |
844 KB |
Output is correct |
21 |
Correct |
5 ms |
844 KB |
Output is correct |
22 |
Correct |
127 ms |
816 KB |
Output is correct |
23 |
Correct |
127 ms |
812 KB |
Output is correct |
24 |
Correct |
130 ms |
820 KB |
Output is correct |
25 |
Correct |
140 ms |
820 KB |
Output is correct |
26 |
Correct |
127 ms |
828 KB |
Output is correct |
27 |
Correct |
7 ms |
1224 KB |
Output is correct |
28 |
Correct |
7 ms |
1356 KB |
Output is correct |
29 |
Correct |
7 ms |
1232 KB |
Output is correct |
30 |
Correct |
514 ms |
1228 KB |
Output is correct |
31 |
Correct |
521 ms |
1228 KB |
Output is correct |
32 |
Correct |
512 ms |
1228 KB |
Output is correct |
33 |
Correct |
63 ms |
9276 KB |
Output is correct |
34 |
Correct |
61 ms |
9300 KB |
Output is correct |
35 |
Correct |
75 ms |
9092 KB |
Output is correct |
36 |
Execution timed out |
3079 ms |
8120 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 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 |
2 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 |
800 KB |
Output is correct |
20 |
Correct |
4 ms |
844 KB |
Output is correct |
21 |
Correct |
5 ms |
844 KB |
Output is correct |
22 |
Correct |
127 ms |
816 KB |
Output is correct |
23 |
Correct |
127 ms |
812 KB |
Output is correct |
24 |
Correct |
130 ms |
820 KB |
Output is correct |
25 |
Correct |
140 ms |
820 KB |
Output is correct |
26 |
Correct |
127 ms |
828 KB |
Output is correct |
27 |
Correct |
199 ms |
25544 KB |
Output is correct |
28 |
Correct |
175 ms |
25412 KB |
Output is correct |
29 |
Correct |
172 ms |
25172 KB |
Output is correct |
30 |
Correct |
166 ms |
25500 KB |
Output is correct |
31 |
Execution timed out |
3068 ms |
21284 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |