이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* There's someone in my head but it's not me */
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define all(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define F first
#define S second
#define lc id << 1
#define rc lc | 1
const int N = 3e5 + 4, MOD = 1e9 + 7;
int n, X[N], Y[N], R[N], ord[N], ret[N], id[N]; ll base[N];
set<pii> seg[N << 1]; vector <ll> cm;
bool cmp(int i, int j) {
if (R[i] == R[j]) return i < j;
return R[i] > R[j];
}
int intersect(int i, int j) {
return (base[i] + base[j] + 2ll * (1ll * X[i] * X[j] + 1ll * Y[i] * Y[j] + 1ll * R[i] * R[j])) >= 0;
}
int lwr(ll x) {
return lower_bound(all(cm), x) - cm.begin();
}
void add(int pos, pii x) {
pos += n;
while (pos) {
seg[pos].insert(x);
pos >>= 1;
}
}
void get(int ql, int qr, ll yl, ll yr, int p) {
ql += n, qr += n + 1;
while (qr - ql > 0) {
if (ql & 1) {
for (auto it = seg[ql].lower_bound({yl, -1e9}); it != seg[ql].end() && it->F <= yr; ) {
if (ret[it->S]) it = seg[ql].erase(it);
else if (intersect(p, it->S)) ret[it->S] = p, it = seg[ql].erase(it);
else it++;
}
ql++;
}
if (qr & 1) {
qr--;
for (auto it = seg[qr].lower_bound({yl, -1e9}); it != seg[qr].end() && it->F <= yr; ) {
if (ret[it->S]) it = seg[qr].erase(it);
else if (intersect(p, it->S)) ret[it->S] = p, it = seg[qr].erase(it);
else it++;
}
}
qr >>= 1, ql >>= 1;
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d%d%d", &X[i], &Y[i], &R[i]), base[i] = 1ll * R[i] * R[i] - 1ll * X[i] * X[i] - 1ll * Y[i] * Y[i], cm.push_back(X[i]), ord[i] = i;
sort(ord + 1, ord + n + 1, cmp);
sort(all(cm));
cm.resize(unique(all(cm)) - cm.begin());
for(int i = 1; i <= n; i ++) {
int I = ord[i];
add(lwr(X[I]) + 1, make_pair(Y[I], I));
}
for (int _ = 1; _ <= n; _++) {
int i = ord[_];
if (ret[i]) continue;
get(lwr(X[i] - 2ll * R[i]) + 1, lwr(X[i] + 2ll * R[i] + 1), Y[i] - 2ll * R[i], Y[i] + 2ll * R[i], i);
}
for (int i = 1; i <= n; i++) printf("%d ", ret[i]);
printf("\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
67 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
circle_selection.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
69 | scanf("%d%d%d", &X[i], &Y[i], &R[i]), base[i] = 1ll * R[i] * R[i] - 1ll * X[i] * X[i] - 1ll * Y[i] * Y[i], cm.push_back(X[i]), ord[i] = 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... |