# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
90978 | tincamatei | Circle selection (APIO18_circle_selection) | C++14 | 3054 ms | 69228 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
unordered_map<int, unordered_map<int, vector<int> > > grid;
const int MAX_N = 300000;
int xc[1+MAX_N], yc[1+MAX_N], rc[1+MAX_N];
int rez[1+MAX_N];
int poz[1+MAX_N];
void rescale(int n, int d) {
grid.clear();
for(int i = 1; i <= n; ++i)
if(rez[i] == 0)
grid[xc[i] / d][yc[i] / d].push_back(i);
}
bool cmp(int a, int b) {
return rc[a] > rc[b] || (rc[a] == rc[b] && a < b);
}
double dist(int a, int b) {
return sqrt((long long)(xc[a] - xc[b]) * (xc[a] - xc[b]) +
(long long)(yc[a] - yc[b]) * (yc[a] - yc[b]));
}
int main() {
#ifdef HOME
FILE *fin = fopen("input.in", "r");
FILE *fout = fopen("output.out", "w");
#else
FILE *fin = stdin;
FILE *fout = stdout;
#endif
int n;
int mnx, mny;
mnx = mny = 1000000000;
fscanf(fin, "%d", &n);
for(int i = 1; i <= n; ++i) {
fscanf(fin, "%d%d%d", &xc[i], &yc[i], &rc[i]);
mnx = min(mnx, xc[i]);
mny = min(mny, yc[i]);
poz[i - 1] = i;
}
for(int i = 1; i <= n; ++i) {
xc[i] -= mnx;
yc[i] -= mny;
}
sort(poz, poz + n, cmp);
int lastr = (1 << 30);
for(int i = 0; i < n; ++i) {
int p = poz[i];
if(rez[p] == 0) {
while(rc[p] < lastr) {
lastr /= 2;
rescale(n, lastr);
}
int x = xc[p] / lastr, y = yc[p] / lastr;
for(int i = x - 2; i <= x + 2; ++i)
for(int j = y - 2; j <= y + 2; ++j)
for(auto it: grid[i][j])
if(rez[it] == 0 && dist(p, it) <= rc[p] + rc[it])
rez[it] = p;
}
}
for(int i = 1; i <= n; ++i)
fprintf(fout, "%d ", rez[i]);
#ifdef HOME
fclose(fin);
fclose(fout);
#endif
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |