#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 < i; 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 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 |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
24 ms |
532 KB |
Output is correct |
23 |
Correct |
22 ms |
532 KB |
Output is correct |
24 |
Correct |
24 ms |
528 KB |
Output is correct |
25 |
Correct |
24 ms |
528 KB |
Output is correct |
26 |
Correct |
23 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
14068 KB |
Output is correct |
2 |
Correct |
163 ms |
14060 KB |
Output is correct |
3 |
Correct |
164 ms |
13800 KB |
Output is correct |
4 |
Correct |
158 ms |
14056 KB |
Output is correct |
5 |
Execution timed out |
3062 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 |
3095 ms |
4228 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3096 ms |
12016 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 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 |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
24 ms |
532 KB |
Output is correct |
23 |
Correct |
22 ms |
532 KB |
Output is correct |
24 |
Correct |
24 ms |
528 KB |
Output is correct |
25 |
Correct |
24 ms |
528 KB |
Output is correct |
26 |
Correct |
23 ms |
508 KB |
Output is correct |
27 |
Correct |
6 ms |
724 KB |
Output is correct |
28 |
Correct |
7 ms |
780 KB |
Output is correct |
29 |
Correct |
6 ms |
724 KB |
Output is correct |
30 |
Correct |
99 ms |
704 KB |
Output is correct |
31 |
Correct |
92 ms |
724 KB |
Output is correct |
32 |
Correct |
98 ms |
704 KB |
Output is correct |
33 |
Correct |
53 ms |
4740 KB |
Output is correct |
34 |
Correct |
58 ms |
4728 KB |
Output is correct |
35 |
Correct |
61 ms |
4728 KB |
Output is correct |
36 |
Execution timed out |
3070 ms |
4216 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 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 |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
24 ms |
532 KB |
Output is correct |
23 |
Correct |
22 ms |
532 KB |
Output is correct |
24 |
Correct |
24 ms |
528 KB |
Output is correct |
25 |
Correct |
24 ms |
528 KB |
Output is correct |
26 |
Correct |
23 ms |
508 KB |
Output is correct |
27 |
Correct |
161 ms |
14068 KB |
Output is correct |
28 |
Correct |
163 ms |
14060 KB |
Output is correct |
29 |
Correct |
164 ms |
13800 KB |
Output is correct |
30 |
Correct |
158 ms |
14056 KB |
Output is correct |
31 |
Execution timed out |
3062 ms |
12024 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |