Submission #252083

# Submission time Handle Problem Language Result Execution time Memory
252083 2020-07-24T06:07:22 Z Mlxa Circle selection (APIO18_circle_selection) C++14
49 / 100
3000 ms 45816 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]);
}

int id(int xi, int yi) {
    return ((xi >> step) << 16)^ (yi >> step);
}
map<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) >= r[i]);
        while ((1LL << step) >= 2 * r[i]) {
            --step;
            build();
        }
        int delta = 1LL << step;
        for (int dx = -2 * delta; dx <= +2 * delta; dx += delta) {
            for (int dy = -2 * delta; dy <= +2 * delta; dy += delta) {
                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 0 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 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 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 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 4 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 4 ms 640 KB Output is correct
22 Correct 25 ms 1152 KB Output is correct
23 Correct 26 ms 1152 KB Output is correct
24 Correct 24 ms 1152 KB Output is correct
25 Correct 29 ms 1152 KB Output is correct
26 Correct 26 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 16868 KB Output is correct
2 Correct 202 ms 16996 KB Output is correct
3 Correct 196 ms 18012 KB Output is correct
4 Correct 190 ms 15852 KB Output is correct
5 Correct 486 ms 19296 KB Output is correct
6 Correct 1458 ms 28208 KB Output is correct
7 Correct 560 ms 19972 KB Output is correct
8 Correct 751 ms 21748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 976 ms 16012 KB Output is correct
3 Execution timed out 3084 ms 45816 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3079 ms 45668 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 0 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 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 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 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 4 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 4 ms 640 KB Output is correct
22 Correct 25 ms 1152 KB Output is correct
23 Correct 26 ms 1152 KB Output is correct
24 Correct 24 ms 1152 KB Output is correct
25 Correct 29 ms 1152 KB Output is correct
26 Correct 26 ms 1152 KB Output is correct
27 Correct 7 ms 1136 KB Output is correct
28 Correct 7 ms 1024 KB Output is correct
29 Correct 7 ms 1024 KB Output is correct
30 Correct 76 ms 1956 KB Output is correct
31 Correct 55 ms 1952 KB Output is correct
32 Correct 55 ms 1920 KB Output is correct
33 Correct 66 ms 6744 KB Output is correct
34 Correct 66 ms 6752 KB Output is correct
35 Correct 74 ms 6456 KB Output is correct
36 Correct 979 ms 16260 KB Output is correct
37 Correct 1034 ms 16196 KB Output is correct
38 Correct 938 ms 16204 KB Output is correct
39 Correct 511 ms 14316 KB Output is correct
40 Correct 505 ms 14400 KB Output is correct
41 Correct 509 ms 14440 KB Output is correct
42 Correct 393 ms 11640 KB Output is correct
43 Correct 789 ms 15816 KB Output is correct
44 Correct 792 ms 15776 KB Output is correct
45 Correct 841 ms 15716 KB Output is correct
46 Correct 798 ms 15816 KB Output is correct
47 Correct 849 ms 15768 KB Output is correct
48 Correct 926 ms 15944 KB Output is correct
49 Correct 800 ms 15824 KB Output is correct
50 Correct 817 ms 15932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 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 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 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 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 4 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 4 ms 640 KB Output is correct
22 Correct 25 ms 1152 KB Output is correct
23 Correct 26 ms 1152 KB Output is correct
24 Correct 24 ms 1152 KB Output is correct
25 Correct 29 ms 1152 KB Output is correct
26 Correct 26 ms 1152 KB Output is correct
27 Correct 198 ms 16868 KB Output is correct
28 Correct 202 ms 16996 KB Output is correct
29 Correct 196 ms 18012 KB Output is correct
30 Correct 190 ms 15852 KB Output is correct
31 Correct 486 ms 19296 KB Output is correct
32 Correct 1458 ms 28208 KB Output is correct
33 Correct 560 ms 19972 KB Output is correct
34 Correct 751 ms 21748 KB Output is correct
35 Correct 0 ms 384 KB Output is correct
36 Correct 976 ms 16012 KB Output is correct
37 Execution timed out 3084 ms 45816 KB Time limit exceeded
38 Halted 0 ms 0 KB -