#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef deque<int> di;
typedef deque<pi> dpi;
typedef deque<bool> db;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<bool> vb;
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define Yes cout << "Yes" << endl
#define endl '\n'
const ll INF = 1e9;
const int MOD = 1e9+7;
const int MAXN = 2e5;
struct circle{
ll r,ind,x,y;
};
bool compare(circle a, circle b){
if (a.r != b.r){
return a.r < b.r;
}
return a.ind < b.ind;
}
void solve()
{
ll n;
cin >> n;
vector<circle>v(n);
for (ll i = 0; i < n; i++){
ll x,y,r;
cin >> x >> y >> r;
v[i].x = x;
v[i].y = y;
v[i].ind = i;
v[i].r = r;
}
sort(all(v),compare);
/* for (int i = 0; i < n; i++){
cout << v[i].r << " ";
} */
vector<ll>rec(n,-1);
for(ll i = n-1; i >= 0; i--){
if(rec[v[i].ind] == -1){
rec[v[i].ind] = v[i].ind+1;
//int cnt = 0;
for (int j = 0; j < n; j++){
if (rec[v[j].ind] == -1 && (abs(v[j].x-v[i].x)*abs(v[j].x-v[i].x))+(abs(v[j].y-v[i].y)*abs(v[j].y-v[i].y))
<= (v[j].r+v[i].r)*(v[j].r+v[i].r)){
rec[v[j].ind] = v[i].ind+1;
//cnt++;
}
}
//cout <<"i: " << i << " cnt: " << cnt << endl;
}
}
/* vi ans(n);
for (int i = 0; i < n; i++){
ans[v[i].ind] = rec[i];
} */
for (int i = 0; i < n; i++){
cout << rec[i] << " ";
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
//To input a whole line without getting seperated by spaces, use getline(cin, string_name)
//Make string to int: stoi(your_String)
//Make int to string: to_string(your_Int)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
492 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
35 ms |
524 KB |
Output is correct |
23 |
Correct |
38 ms |
524 KB |
Output is correct |
24 |
Correct |
36 ms |
524 KB |
Output is correct |
25 |
Correct |
47 ms |
468 KB |
Output is correct |
26 |
Correct |
48 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
182 ms |
14188 KB |
Output is correct |
2 |
Correct |
157 ms |
14112 KB |
Output is correct |
3 |
Correct |
162 ms |
13800 KB |
Output is correct |
4 |
Correct |
154 ms |
14056 KB |
Output is correct |
5 |
Execution timed out |
3055 ms |
12024 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
3064 ms |
4228 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3056 ms |
12012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
492 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
35 ms |
524 KB |
Output is correct |
23 |
Correct |
38 ms |
524 KB |
Output is correct |
24 |
Correct |
36 ms |
524 KB |
Output is correct |
25 |
Correct |
47 ms |
468 KB |
Output is correct |
26 |
Correct |
48 ms |
512 KB |
Output is correct |
27 |
Correct |
5 ms |
724 KB |
Output is correct |
28 |
Correct |
6 ms |
852 KB |
Output is correct |
29 |
Correct |
5 ms |
724 KB |
Output is correct |
30 |
Correct |
151 ms |
708 KB |
Output is correct |
31 |
Correct |
168 ms |
716 KB |
Output is correct |
32 |
Correct |
146 ms |
724 KB |
Output is correct |
33 |
Correct |
53 ms |
4736 KB |
Output is correct |
34 |
Correct |
57 ms |
4728 KB |
Output is correct |
35 |
Correct |
69 ms |
4728 KB |
Output is correct |
36 |
Execution timed out |
3063 ms |
4224 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
492 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
35 ms |
524 KB |
Output is correct |
23 |
Correct |
38 ms |
524 KB |
Output is correct |
24 |
Correct |
36 ms |
524 KB |
Output is correct |
25 |
Correct |
47 ms |
468 KB |
Output is correct |
26 |
Correct |
48 ms |
512 KB |
Output is correct |
27 |
Correct |
182 ms |
14188 KB |
Output is correct |
28 |
Correct |
157 ms |
14112 KB |
Output is correct |
29 |
Correct |
162 ms |
13800 KB |
Output is correct |
30 |
Correct |
154 ms |
14056 KB |
Output is correct |
31 |
Execution timed out |
3055 ms |
12024 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |