Submission #261002

# Submission time Handle Problem Language Result Execution time Memory
261002 2020-08-11T09:39:18 Z SorahISA Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 26328 KB
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)

const int INF = 0x7f7f7f7f;
const int maxn = 3E5 + 5;

struct Circle {
    int x, y, r, id;
    bool operator < (const Circle &rhs) const {
        if (r == rhs.r) return id > rhs.id;
        return r < rhs.r;
    }
};

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
    Prior<Circle> pq;
    vector<Circle> cir(n);
    for (int i = 0; i < n; ++i) {
        cin >> cir[i].x >> cir[i].y >> cir[i].r;
        cir[i].id = i;
        pq.push(cir[i]);
    }
    
    vector<int> ans(n, -1);
    for (int i = 0; i < n; ++i) {
        while (!pq.empty() and ans[pq.top().id] != -1) pq.pop();
        for (int j = 0; j < n; ++j) {
            if (ans[j] != -1) continue;
            int dx = abs(cir[pq.top().id].x - cir[j].x);
            int dy = abs(cir[pq.top().id].y - cir[j].y);
            int dr =     cir[pq.top().id].r + cir[j].r;
            // cout << dx << " " << dy << " " << dr << "\n";
            if (dx*dx + dy*dy <= dr*dr) ans[j] = pq.top().id;
        }
    }
    
    for (int i = 0; i < n; ++i) cout << ans[i] + 1 << " \n"[i == n-1];
    
    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 1 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 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 22 ms 896 KB Output is correct
20 Correct 22 ms 896 KB Output is correct
21 Correct 23 ms 896 KB Output is correct
22 Correct 70 ms 896 KB Output is correct
23 Correct 62 ms 896 KB Output is correct
24 Correct 71 ms 896 KB Output is correct
25 Correct 63 ms 896 KB Output is correct
26 Correct 71 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 26328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Execution timed out 3061 ms 7776 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 26328 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 1 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 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 22 ms 896 KB Output is correct
20 Correct 22 ms 896 KB Output is correct
21 Correct 23 ms 896 KB Output is correct
22 Correct 70 ms 896 KB Output is correct
23 Correct 62 ms 896 KB Output is correct
24 Correct 71 ms 896 KB Output is correct
25 Correct 63 ms 896 KB Output is correct
26 Correct 71 ms 896 KB Output is correct
27 Correct 84 ms 1408 KB Output is correct
28 Correct 91 ms 1280 KB Output is correct
29 Correct 83 ms 1280 KB Output is correct
30 Correct 289 ms 1280 KB Output is correct
31 Correct 287 ms 1280 KB Output is correct
32 Correct 285 ms 1280 KB Output is correct
33 Execution timed out 3047 ms 7660 KB Time limit exceeded
34 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 1 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 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 22 ms 896 KB Output is correct
20 Correct 22 ms 896 KB Output is correct
21 Correct 23 ms 896 KB Output is correct
22 Correct 70 ms 896 KB Output is correct
23 Correct 62 ms 896 KB Output is correct
24 Correct 71 ms 896 KB Output is correct
25 Correct 63 ms 896 KB Output is correct
26 Correct 71 ms 896 KB Output is correct
27 Execution timed out 3052 ms 26328 KB Time limit exceeded
28 Halted 0 ms 0 KB -