Submission #252077

# Submission time Handle Problem Language Result Execution time Memory
252077 2020-07-24T05:59:01 Z Mlxa Circle selection (APIO18_circle_selection) C++14
49 / 100
3000 ms 45796 KB
#include <bits/stdc++.h>
using ll = long long;
#define int ll
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
using namespace std;

const int N = 3e5 + 5;
int n;
int x[N];
int y[N];
int r[N];
int a[N];
int step = 32;
vector<int> desc;

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

pair<int, int> id(int xi, int yi) {
    return {(xi >> step), (yi >> step)};
}
map<pair<int, int>, vector<int>> table;

void build() {
    table.clear();
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) {
            table[id(x[i], y[i])].push_back(i);
        }
    }
}

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif // LC
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> r[i];
        a[i] = -1;
        desc.push_back(i);
    }
    sort(all(desc), [&](int i, int j) {
         return mp(-r[i], i) < mp(-r[j], j);
    });
    for (int i : desc) {
        if (a[i] != -1) {
            continue;
        }
        assert((1LL << step) >= 2 * r[i]);
        while ((1LL << step) >= 4 * r[i]) {
            --step;
            build();
        }
        int delta = 1LL << step;
        assert(2 * r[i] <= delta && delta < 4 * r[i]);
        for (int dx = -2 * delta; dx <= +2 * delta; dx += delta) {
            for (int dy = -2 * delta; dy <= +2 * delta; dy += delta) {
                pair<int, int> v = id(x[i] + dx, y[i] + dy);
                if (!table.count(v)) {
                    continue;
                }
                vector<int> tmp;
                for (int j : table[v]) {
                    if (cross(i, j)) {
                        assert(a[j] == -1);
                        a[j] = i;
                    } else {
                        tmp.push_back(j);
                    }
                }
                table[v] = tmp;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] + 1 << " ";
    }
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 4 ms 896 KB Output is correct
21 Correct 4 ms 896 KB Output is correct
22 Correct 27 ms 1280 KB Output is correct
23 Correct 28 ms 1280 KB Output is correct
24 Correct 27 ms 1280 KB Output is correct
25 Correct 28 ms 1280 KB Output is correct
26 Correct 27 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 183 ms 17376 KB Output is correct
2 Correct 206 ms 23848 KB Output is correct
3 Correct 194 ms 22584 KB Output is correct
4 Correct 221 ms 20836 KB Output is correct
5 Correct 462 ms 23768 KB Output is correct
6 Correct 1384 ms 28732 KB Output is correct
7 Correct 600 ms 24712 KB Output is correct
8 Correct 766 ms 24908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1022 ms 16312 KB Output is correct
3 Execution timed out 3087 ms 45668 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3077 ms 45796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 4 ms 896 KB Output is correct
21 Correct 4 ms 896 KB Output is correct
22 Correct 27 ms 1280 KB Output is correct
23 Correct 28 ms 1280 KB Output is correct
24 Correct 27 ms 1280 KB Output is correct
25 Correct 28 ms 1280 KB Output is correct
26 Correct 27 ms 1280 KB Output is correct
27 Correct 7 ms 1444 KB Output is correct
28 Correct 7 ms 1280 KB Output is correct
29 Correct 7 ms 1280 KB Output is correct
30 Correct 58 ms 2216 KB Output is correct
31 Correct 56 ms 2228 KB Output is correct
32 Correct 58 ms 2176 KB Output is correct
33 Correct 67 ms 8944 KB Output is correct
34 Correct 65 ms 8940 KB Output is correct
35 Correct 74 ms 9056 KB Output is correct
36 Correct 1197 ms 18700 KB Output is correct
37 Correct 1289 ms 18848 KB Output is correct
38 Correct 1176 ms 18888 KB Output is correct
39 Correct 708 ms 12344 KB Output is correct
40 Correct 675 ms 12336 KB Output is correct
41 Correct 735 ms 12400 KB Output is correct
42 Correct 466 ms 9708 KB Output is correct
43 Correct 913 ms 18356 KB Output is correct
44 Correct 981 ms 18276 KB Output is correct
45 Correct 888 ms 18156 KB Output is correct
46 Correct 921 ms 18228 KB Output is correct
47 Correct 917 ms 18420 KB Output is correct
48 Correct 1010 ms 18444 KB Output is correct
49 Correct 948 ms 18360 KB Output is correct
50 Correct 915 ms 18180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 4 ms 896 KB Output is correct
21 Correct 4 ms 896 KB Output is correct
22 Correct 27 ms 1280 KB Output is correct
23 Correct 28 ms 1280 KB Output is correct
24 Correct 27 ms 1280 KB Output is correct
25 Correct 28 ms 1280 KB Output is correct
26 Correct 27 ms 1280 KB Output is correct
27 Correct 183 ms 17376 KB Output is correct
28 Correct 206 ms 23848 KB Output is correct
29 Correct 194 ms 22584 KB Output is correct
30 Correct 221 ms 20836 KB Output is correct
31 Correct 462 ms 23768 KB Output is correct
32 Correct 1384 ms 28732 KB Output is correct
33 Correct 600 ms 24712 KB Output is correct
34 Correct 766 ms 24908 KB Output is correct
35 Correct 0 ms 384 KB Output is correct
36 Correct 1022 ms 16312 KB Output is correct
37 Execution timed out 3087 ms 45668 KB Time limit exceeded
38 Halted 0 ms 0 KB -