#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init() {
#ifndef ONLINE_JUDGE
FILE* _ = freopen("in.txt", "r", stdin);
start_time = clock();
#endif
}
const ll MOD = 998244353;
const ll N = 6e5 + 1;
const ll M = 2e2 + 1;
using namespace std;
//####################################################################################
bool comp(array<int, 4> a, array<int, 4> b) {
if (a[0] == b[0])
return a[3] < b[3];
return a[0] > b[0];
}
int dist(int x1, int y1, int x2, int y2) {
float f = ceil(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
return (int)f;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); //init();
int n;
cin >> n;
vector< array<int, 4> > v(n); // {radius, x, y, idx}
for (int i = 0; i < n; i++)
cin >> v[i][1] >> v[i][2] >> v[i][0], v[i][3] = i + 1;
sort(all(v), comp);
vector<int> ans(n + 1, 0);
for (int i = 0; i < n; i++) {
if (ans[v[i][3]])
continue;
ans[v[i][3]] = v[i][3];
for (int j = i + 1; j < n; j++) {
if (!ans[v[j][3]] && dist(v[i][1], v[i][2], v[j][1], v[j][2]) <= v[i][0] + v[j][0])
ans[v[j][3]] = v[i][3];
}
}
for (int i = 1; i <= n; i++)
cout << ans[i] << ' ';
cout << endl;
cerr << get_time() << "s" << endl;
}
Compilation message
circle_selection.cpp: In function 'void init()':
circle_selection.cpp:10:8: warning: unused variable '_' [-Wunused-variable]
10 | FILE* _ = freopen("in.txt", "r", stdin);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
128 ms |
8204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
130 ms |
6824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |