답안 #87154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87154 2018-11-29T18:52:41 Z fedoseevtimofey 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 22996 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int n;
vector <int> x, y, r;

void init() {
    cin >> n;
    x.resize(n);
    y.resize(n);
    r.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> r[i];
    }
}

bool inter(int i, int j) {
    return (ll)(x[i] - x[j]) * (x[i] - x[j]) + (ll)(y[i] - y[j]) * (y[i] - y[j]) <= (ll)(r[i] + r[j]) * (r[i] + r[j]);
}

map <pair <int, int>, vector <int>> who;

set <int> alive;

void rebuild(int B) {
    who.clear();
    for (auto i : alive) {
        int xx = x[i] / B;
        int yy = y[i] / B;
        who[make_pair(xx, yy)].push_back(i);
    }
}

void solve() {
    for (int i = 0; i < n; ++i) alive.insert(i);
    vector <int> idx(n);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&] (int i, int j) {
        if (r[i] != r[j]) return r[i] > r[j];
        return i < j;
    });
    vector <int> kill(n, -1);
    int uk = 0;
    for (int B = 1 << 30; B > 0; B >>= 1) {
        rebuild(B);
        while (true) {
            while (uk < n && kill[idx[uk]] != -1) ++uk;
            if (uk == n) break;
            int cur = idx[uk];
            alive.erase(cur);
            kill[cur] = cur;
            int xx = x[cur] / B;
            int yy = y[cur] / B;
            for (int cx = xx - 2; cx <= xx + 2; ++cx) {
                for (int cy = yy - 2; cy <= yy + 2; ++cy) {
                    for (auto j : who[make_pair(cx, cy)]) {
                        if (kill[j] != -1) continue;
                        if (inter(cur, j)) {
                            kill[j] = cur;
                            alive.erase(j);
                        }
                    }
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << kill[i] + 1 << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    init();
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 648 KB Output is correct
7 Correct 2 ms 648 KB Output is correct
8 Correct 2 ms 648 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 3 ms 712 KB Output is correct
18 Correct 3 ms 712 KB Output is correct
19 Correct 6 ms 1024 KB Output is correct
20 Correct 6 ms 1024 KB Output is correct
21 Correct 7 ms 1036 KB Output is correct
22 Correct 143 ms 1036 KB Output is correct
23 Correct 146 ms 1036 KB Output is correct
24 Correct 158 ms 1052 KB Output is correct
25 Correct 141 ms 1052 KB Output is correct
26 Correct 144 ms 1052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 331 ms 22920 KB Output is correct
2 Correct 371 ms 22920 KB Output is correct
3 Correct 365 ms 22920 KB Output is correct
4 Correct 322 ms 22996 KB Output is correct
5 Execution timed out 3021 ms 22996 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 22996 KB Output is correct
2 Execution timed out 3051 ms 22996 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 22996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 648 KB Output is correct
7 Correct 2 ms 648 KB Output is correct
8 Correct 2 ms 648 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 3 ms 712 KB Output is correct
18 Correct 3 ms 712 KB Output is correct
19 Correct 6 ms 1024 KB Output is correct
20 Correct 6 ms 1024 KB Output is correct
21 Correct 7 ms 1036 KB Output is correct
22 Correct 143 ms 1036 KB Output is correct
23 Correct 146 ms 1036 KB Output is correct
24 Correct 158 ms 1052 KB Output is correct
25 Correct 141 ms 1052 KB Output is correct
26 Correct 144 ms 1052 KB Output is correct
27 Correct 11 ms 22996 KB Output is correct
28 Correct 10 ms 22996 KB Output is correct
29 Correct 10 ms 22996 KB Output is correct
30 Correct 590 ms 22996 KB Output is correct
31 Correct 593 ms 22996 KB Output is correct
32 Correct 725 ms 22996 KB Output is correct
33 Correct 102 ms 22996 KB Output is correct
34 Correct 101 ms 22996 KB Output is correct
35 Correct 116 ms 22996 KB Output is correct
36 Execution timed out 3041 ms 22996 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 648 KB Output is correct
7 Correct 2 ms 648 KB Output is correct
8 Correct 2 ms 648 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 3 ms 712 KB Output is correct
18 Correct 3 ms 712 KB Output is correct
19 Correct 6 ms 1024 KB Output is correct
20 Correct 6 ms 1024 KB Output is correct
21 Correct 7 ms 1036 KB Output is correct
22 Correct 143 ms 1036 KB Output is correct
23 Correct 146 ms 1036 KB Output is correct
24 Correct 158 ms 1052 KB Output is correct
25 Correct 141 ms 1052 KB Output is correct
26 Correct 144 ms 1052 KB Output is correct
27 Correct 331 ms 22920 KB Output is correct
28 Correct 371 ms 22920 KB Output is correct
29 Correct 365 ms 22920 KB Output is correct
30 Correct 322 ms 22996 KB Output is correct
31 Execution timed out 3021 ms 22996 KB Time limit exceeded
32 Halted 0 ms 0 KB -