답안 #87165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87165 2018-11-29T19:41:59 Z fedoseevtimofey 원 고르기 (APIO18_circle_selection) C++14
49 / 100
3000 ms 457552 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
int n;
vector <int> x, y, r;
vector <int> _kill;
 
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;
 
 
void rebuild(int B) {
    who.clear();
    for (int i = 0; i < n; ++i) {
        if (_kill[i] != -1) continue;
        int xx = x[i] / B;
        int yy = y[i] / B;
        who[make_pair(xx, yy)].push_back(i);
    }
}
 
void solve() {
    _kill.resize(n, -1);
    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;
    });
    int uk = 0;
    int B = 2e9 + 7;
    while (true) {
        while (uk < n && _kill[idx[uk]] != -1) ++uk;
        if (uk == n) break;
        int cur = idx[uk];
        if ((r[cur] << 1) <= B) {
            B = r[cur];
            rebuild(B);
        }
        _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 && inter(cur, j)) {
                        _kill[j] = cur;
                    }
                }
            }
        }
    }
    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 508 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 3 ms 788 KB Output is correct
15 Correct 2 ms 788 KB Output is correct
16 Correct 3 ms 788 KB Output is correct
17 Correct 3 ms 872 KB Output is correct
18 Correct 3 ms 872 KB Output is correct
19 Correct 5 ms 872 KB Output is correct
20 Correct 5 ms 1000 KB Output is correct
21 Correct 6 ms 1000 KB Output is correct
22 Correct 40 ms 6248 KB Output is correct
23 Correct 43 ms 6248 KB Output is correct
24 Correct 44 ms 6248 KB Output is correct
25 Correct 38 ms 6248 KB Output is correct
26 Correct 41 ms 6248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 187 ms 12464 KB Output is correct
2 Correct 200 ms 13136 KB Output is correct
3 Correct 187 ms 13500 KB Output is correct
4 Correct 188 ms 13500 KB Output is correct
5 Correct 254 ms 16616 KB Output is correct
6 Correct 1375 ms 88976 KB Output is correct
7 Correct 361 ms 88976 KB Output is correct
8 Correct 511 ms 88976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 88976 KB Output is correct
2 Correct 1484 ms 112628 KB Output is correct
3 Execution timed out 3070 ms 324976 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3069 ms 457552 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 508 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 3 ms 788 KB Output is correct
15 Correct 2 ms 788 KB Output is correct
16 Correct 3 ms 788 KB Output is correct
17 Correct 3 ms 872 KB Output is correct
18 Correct 3 ms 872 KB Output is correct
19 Correct 5 ms 872 KB Output is correct
20 Correct 5 ms 1000 KB Output is correct
21 Correct 6 ms 1000 KB Output is correct
22 Correct 40 ms 6248 KB Output is correct
23 Correct 43 ms 6248 KB Output is correct
24 Correct 44 ms 6248 KB Output is correct
25 Correct 38 ms 6248 KB Output is correct
26 Correct 41 ms 6248 KB Output is correct
27 Correct 8 ms 457552 KB Output is correct
28 Correct 9 ms 457552 KB Output is correct
29 Correct 8 ms 457552 KB Output is correct
30 Correct 108 ms 457552 KB Output is correct
31 Correct 93 ms 457552 KB Output is correct
32 Correct 84 ms 457552 KB Output is correct
33 Correct 70 ms 457552 KB Output is correct
34 Correct 71 ms 457552 KB Output is correct
35 Correct 85 ms 457552 KB Output is correct
36 Correct 1548 ms 457552 KB Output is correct
37 Correct 1340 ms 457552 KB Output is correct
38 Correct 1414 ms 457552 KB Output is correct
39 Correct 459 ms 457552 KB Output is correct
40 Correct 582 ms 457552 KB Output is correct
41 Correct 524 ms 457552 KB Output is correct
42 Correct 292 ms 457552 KB Output is correct
43 Correct 1022 ms 457552 KB Output is correct
44 Correct 1041 ms 457552 KB Output is correct
45 Correct 1034 ms 457552 KB Output is correct
46 Correct 1058 ms 457552 KB Output is correct
47 Correct 1095 ms 457552 KB Output is correct
48 Correct 1051 ms 457552 KB Output is correct
49 Correct 1061 ms 457552 KB Output is correct
50 Correct 1014 ms 457552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 3 ms 788 KB Output is correct
15 Correct 2 ms 788 KB Output is correct
16 Correct 3 ms 788 KB Output is correct
17 Correct 3 ms 872 KB Output is correct
18 Correct 3 ms 872 KB Output is correct
19 Correct 5 ms 872 KB Output is correct
20 Correct 5 ms 1000 KB Output is correct
21 Correct 6 ms 1000 KB Output is correct
22 Correct 40 ms 6248 KB Output is correct
23 Correct 43 ms 6248 KB Output is correct
24 Correct 44 ms 6248 KB Output is correct
25 Correct 38 ms 6248 KB Output is correct
26 Correct 41 ms 6248 KB Output is correct
27 Correct 187 ms 12464 KB Output is correct
28 Correct 200 ms 13136 KB Output is correct
29 Correct 187 ms 13500 KB Output is correct
30 Correct 188 ms 13500 KB Output is correct
31 Correct 254 ms 16616 KB Output is correct
32 Correct 1375 ms 88976 KB Output is correct
33 Correct 361 ms 88976 KB Output is correct
34 Correct 511 ms 88976 KB Output is correct
35 Correct 2 ms 88976 KB Output is correct
36 Correct 1484 ms 112628 KB Output is correct
37 Execution timed out 3070 ms 324976 KB Time limit exceeded
38 Halted 0 ms 0 KB -