This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300'000;
ll n, x[N + 10], y[N + 10], r[N + 10];
int ans[N + 10], id[N + 10];
pair<int, int> p[N + 10];
void readInput() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> r[i];
p[i] = {r[i], -i};
}
sort(p + 1, p + n + 1);
for (int i = 1; i <= n; i++)
id[i] = -p[i].second;
}
ll p2(ll x) {
return x * x;
}
bool check(int i, int j) {
ll dis = p2(x[i] - x[j]) + p2(y[i] - y[j]);
return dis <= p2(r[i] + r[j]);
}
void solve1() {
for (int i = n; i >= 1; i--)
if (!ans[id[i]]) {
ans[id[i]] = id[i];
for (int j = 1; j < i; j++)
if (check(id[i], id[j]) && !ans[id[j]])
ans[id[j]] = id[i];
}
}
void writeOutput() {
for (int i = 1; i <= n; i++)
cout << ans[i] << ' ';
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
readInput();
solve1();
writeOutput();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |