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("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)
const int INF = 0x7f7f7f7f;
const int maxn = 3E5 + 5;
struct Circle {
int x, y, r, id;
bool operator < (const Circle &rhs) const {
if (r == rhs.r) return id > rhs.id;
return r < rhs.r;
}
};
int32_t main() {
fastIO();
int n;
cin >> n;
Prior<Circle> pq;
vector<Circle> cir(n);
for (int i = 0; i < n; ++i) {
cin >> cir[i].x >> cir[i].y >> cir[i].r;
cir[i].id = i;
pq.push(cir[i]);
}
vector<int> ans(n, -1);
for (int i = 0; i < n; ++i) {
while (!pq.empty() and ans[pq.top().id] != -1) pq.pop();
for (int j = 0; j < n; ++j) {
if (ans[j] != -1) continue;
int dx = abs(cir[pq.top().id].x - cir[j].x);
int dy = abs(cir[pq.top().id].y - cir[j].y);
int dr = cir[pq.top().id].r + cir[j].r;
// cout << dx << " " << dy << " " << dr << "\n";
if (dx*dx + dy*dy <= dr*dr) ans[j] = pq.top().id;
}
}
for (int i = 0; i < n; ++i) cout << ans[i] + 1 << " \n"[i == n-1];
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... |