This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt")
#include <bits/stdc++.h>
#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define left leftt
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvi = vt< vt<int> >;
const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e18 + 7, B = 500, LIM = (1ll << 60);
const double eps = 1e-6;
int n, x[N], y[N], r[N], ans[N];
bool inter (int x1, int x2, int y1, int y2, int r1, int r2) {
int x = x1 - x2, y = y1 - y2, r = r1 + r2;
x *= x, y *= y, r *= r;
return (x + y <= r);
}
void solve () {
cin >> n;
for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
vt<int> left(n + 1, 1);
while (true) {
bool ok = 0;
for (int i = 1; i <= n; i++) ok |= left[i];
if (!ok) break;
int mx = 0, pos = 0;
for (int i = 1; i <= n; i++) {
if (left[i] && mx < r[i]) mx = r[i], pos = i;
}
for (int i = 1; i <= n; i++) {
if (left[i] && inter(x[i], x[pos], y[i], y[pos], r[i], r[pos])) ans[i] = pos, left[i] = 0;
}
}
for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
cout << '\n';
}
bool testcases = 0;
signed main() {
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
cin.tie(0) -> sync_with_stdio(0);
int test = 1;
if (testcases) cin >> test;
for (int cs = 1; cs <= test; cs++) {
solve();
}
}
# | 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... |