이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 300005
#define M ll(998244353)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
int ans[n];
for (int i = 0; i < n; i++) ans[i] = -1;
ld x[n], y[n], r[n];
for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
int s = n;
while (s > 0)
{
int nm = -1;
for (int i = 0; i < n; i++)
{
if (ans[i] != -1) continue;
if (nm == -1 || r[nm] < r[i]) nm = i;
}
for (int i = 0; i < n; i++)
{
if (ans[i] != -1) continue;
ld rst = sqrt(pow(abs(x[nm] - x[i]), 2) + pow(abs(y[nm] - y[i]), 2));
if (r[nm] + r[i] >= rst) {ans[i] = nm + 1; s--;}
}
}
for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
| # | 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... |