| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 902378 | Trisanu_Das | 원 고르기 (APIO18_circle_selection) | C++17 | 2595 ms | 63380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = (int)3e5+ 7;
int x[N], y[N], r[N], n, ans[N], pos[N], block = 0;
map<pair<int, int>, vector<int>> mp;
set <int> ost;
ll sqr(ll x) {
return x * x;
}
ll dist(int x1, int y1, int x2, int y2) {
return sqr(x1 - x2) + sqr(y1 - y2);
}
void rescale() {
mp.clear();
for (int to : ost) mp[{x[to] / block, y[to] / block}].push_back(to);
}
main() {
iota(pos, pos + N, 0);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d %d %d", &x[i], &y[i], &r[i]);
ost.insert(i);
}
sort(pos + 1, pos + n + 1, [&](const int &A, const int &B) {
if (r[A] == r[B]) return A < B;
return r[A] > r[B];
});
for (int i = 1; i <= n; i++) {
if (ans[pos[i]]) continue;
if (block == 0 || r[pos[i]] * 2 <= block) {
block = r[pos[i]];
rescale();
}
for (int cx = x[pos[i]] / block - 2; cx <= x[pos[i]] / block + 2; cx++) {
for (int cy = y[pos[i]] / block - 2; cy <= y[pos[i]] / block + 2; cy++) {
if (!mp.count({cx, cy})) continue;
for (int to : mp[{cx, cy}]) {
if (!ans[to] && dist(x[pos[i]], y[pos[i]], x[to], y[to]) <= sqr(r[pos[i]] + r[to])) {
ans[to] = pos[i];
ost.erase(to);
}
}
}
}
}
for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
