이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*input
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin >> n;
ll x[n], y[n], r[n];
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i] >> r[i];
int a[n];
iota(a, a + n, 0);
sort(a, a + n, [&](int x, int y) {
if (r[x] != r[y])
return r[x] > r[y];
else
return x < y;
});
int ans[n];
fill_n(ans, n, -1);
for (int i = 0; i < n; i++)
{
if (ans[a[i]] != -1)
continue;
for (int j = i; j < n; j++)
{
if (ans[a[j]] != -1)
continue;
if ((x[a[i]] - x[a[j]]) * (x[a[i]] - x[a[j]]) +
(y[a[i]] - y[a[j]]) * (y[a[i]] - y[a[j]]) <=
(r[a[i]] + r[a[j]]) * (r[a[i]] + r[a[j]]))
{
ans[a[j]] = a[i];
}
}
}
for (int i = 0; i < n; i++)
cout << ans[i] + 1 << " ";
cout << "\n";
}
| # | 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... |