Submission #252089

# Submission time Handle Problem Language Result Execution time Memory
252089 2020-07-24T06:15:32 Z Mlxa Circle selection (APIO18_circle_selection) C++14
87 / 100
3000 ms 55220 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 = 30;
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);
    });
    build();
    for (int i : desc) {
        if (a[i] != -1) {
            continue;
        }
        assert((1LL << step) >= r[i]);
        if ((1LL << step) >= 2 * 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) {
                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 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 0 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 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 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 3 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 4 ms 768 KB Output is correct
22 Correct 15 ms 1184 KB Output is correct
23 Correct 17 ms 1152 KB Output is correct
24 Correct 15 ms 1152 KB Output is correct
25 Correct 13 ms 1152 KB Output is correct
26 Correct 15 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 16864 KB Output is correct
2 Correct 204 ms 17008 KB Output is correct
3 Correct 196 ms 17932 KB Output is correct
4 Correct 203 ms 15768 KB Output is correct
5 Correct 260 ms 18276 KB Output is correct
6 Correct 891 ms 28332 KB Output is correct
7 Correct 309 ms 19500 KB Output is correct
8 Correct 393 ms 21672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 572 ms 15796 KB Output is correct
3 Correct 2140 ms 47104 KB Output is correct
4 Correct 2179 ms 46924 KB Output is correct
5 Correct 2415 ms 41372 KB Output is correct
6 Correct 983 ms 20604 KB Output is correct
7 Correct 335 ms 11128 KB Output is correct
8 Correct 41 ms 2584 KB Output is correct
9 Correct 2614 ms 45796 KB Output is correct
10 Correct 1910 ms 38304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2027 ms 47064 KB Output is correct
2 Correct 1225 ms 46932 KB Output is correct
3 Correct 541 ms 23476 KB Output is correct
4 Correct 1421 ms 47064 KB Output is correct
5 Correct 1406 ms 46936 KB Output is correct
6 Correct 331 ms 18796 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 0 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 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 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 3 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 4 ms 768 KB Output is correct
22 Correct 15 ms 1184 KB Output is correct
23 Correct 17 ms 1152 KB Output is correct
24 Correct 15 ms 1152 KB Output is correct
25 Correct 13 ms 1152 KB Output is correct
26 Correct 15 ms 1152 KB Output is correct
27 Correct 8 ms 1136 KB Output is correct
28 Correct 8 ms 1024 KB Output is correct
29 Correct 7 ms 1024 KB Output is correct
30 Correct 39 ms 1908 KB Output is correct
31 Correct 33 ms 1916 KB Output is correct
32 Correct 31 ms 1912 KB Output is correct
33 Correct 71 ms 5872 KB Output is correct
34 Correct 71 ms 5872 KB Output is correct
35 Correct 82 ms 6368 KB Output is correct
36 Correct 562 ms 15824 KB Output is correct
37 Correct 633 ms 15820 KB Output is correct
38 Correct 606 ms 15936 KB Output is correct
39 Correct 421 ms 14276 KB Output is correct
40 Correct 425 ms 14296 KB Output is correct
41 Correct 415 ms 14288 KB Output is correct
42 Correct 444 ms 11632 KB Output is correct
43 Correct 320 ms 15568 KB Output is correct
44 Correct 364 ms 15628 KB Output is correct
45 Correct 396 ms 15624 KB Output is correct
46 Correct 322 ms 15664 KB Output is correct
47 Correct 323 ms 15612 KB Output is correct
48 Correct 335 ms 15556 KB Output is correct
49 Correct 379 ms 15560 KB Output is correct
50 Correct 323 ms 15612 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 0 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 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 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 3 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 4 ms 768 KB Output is correct
22 Correct 15 ms 1184 KB Output is correct
23 Correct 17 ms 1152 KB Output is correct
24 Correct 15 ms 1152 KB Output is correct
25 Correct 13 ms 1152 KB Output is correct
26 Correct 15 ms 1152 KB Output is correct
27 Correct 194 ms 16864 KB Output is correct
28 Correct 204 ms 17008 KB Output is correct
29 Correct 196 ms 17932 KB Output is correct
30 Correct 203 ms 15768 KB Output is correct
31 Correct 260 ms 18276 KB Output is correct
32 Correct 891 ms 28332 KB Output is correct
33 Correct 309 ms 19500 KB Output is correct
34 Correct 393 ms 21672 KB Output is correct
35 Correct 0 ms 384 KB Output is correct
36 Correct 572 ms 15796 KB Output is correct
37 Correct 2140 ms 47104 KB Output is correct
38 Correct 2179 ms 46924 KB Output is correct
39 Correct 2415 ms 41372 KB Output is correct
40 Correct 983 ms 20604 KB Output is correct
41 Correct 335 ms 11128 KB Output is correct
42 Correct 41 ms 2584 KB Output is correct
43 Correct 2614 ms 45796 KB Output is correct
44 Correct 1910 ms 38304 KB Output is correct
45 Correct 2027 ms 47064 KB Output is correct
46 Correct 1225 ms 46932 KB Output is correct
47 Correct 541 ms 23476 KB Output is correct
48 Correct 1421 ms 47064 KB Output is correct
49 Correct 1406 ms 46936 KB Output is correct
50 Correct 331 ms 18796 KB Output is correct
51 Correct 8 ms 1136 KB Output is correct
52 Correct 8 ms 1024 KB Output is correct
53 Correct 7 ms 1024 KB Output is correct
54 Correct 39 ms 1908 KB Output is correct
55 Correct 33 ms 1916 KB Output is correct
56 Correct 31 ms 1912 KB Output is correct
57 Correct 71 ms 5872 KB Output is correct
58 Correct 71 ms 5872 KB Output is correct
59 Correct 82 ms 6368 KB Output is correct
60 Correct 562 ms 15824 KB Output is correct
61 Correct 633 ms 15820 KB Output is correct
62 Correct 606 ms 15936 KB Output is correct
63 Correct 421 ms 14276 KB Output is correct
64 Correct 425 ms 14296 KB Output is correct
65 Correct 415 ms 14288 KB Output is correct
66 Correct 444 ms 11632 KB Output is correct
67 Correct 320 ms 15568 KB Output is correct
68 Correct 364 ms 15628 KB Output is correct
69 Correct 396 ms 15624 KB Output is correct
70 Correct 322 ms 15664 KB Output is correct
71 Correct 323 ms 15612 KB Output is correct
72 Correct 335 ms 15556 KB Output is correct
73 Correct 379 ms 15560 KB Output is correct
74 Correct 323 ms 15612 KB Output is correct
75 Correct 250 ms 27488 KB Output is correct
76 Correct 232 ms 27560 KB Output is correct
77 Correct 232 ms 29480 KB Output is correct
78 Correct 227 ms 27228 KB Output is correct
79 Correct 298 ms 26956 KB Output is correct
80 Correct 223 ms 27236 KB Output is correct
81 Correct 2462 ms 54964 KB Output is correct
82 Correct 2055 ms 54860 KB Output is correct
83 Correct 2098 ms 54848 KB Output is correct
84 Correct 2505 ms 55220 KB Output is correct
85 Correct 2093 ms 55012 KB Output is correct
86 Correct 1934 ms 54988 KB Output is correct
87 Execution timed out 3027 ms 54640 KB Time limit exceeded
88 Halted 0 ms 0 KB -