Submission #1075389

# Submission time Handle Problem Language Result Execution time Memory
1075389 2024-08-26T05:12:52 Z HappyCapybara Circle selection (APIO18_circle_selection) C++17
19 / 100
550 ms 62640 KB
#include<bits/stdc++.h>
using namespace std;

double eps = pow(10, -9);

double dist(int ax, int ay, int bx, int by){
    return sqrt(pow(ax-bx, 2)+pow(ay-by, 2));
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(n);
    vector<pair<int,int>> ep;
    for (int i=0; i<n; i++){
        int x, y, r;
        cin >> x >> y >> r;
        v[i] = {-r, i, x, y};
    }

    sort(v.begin(), v.end());
    for (int i=0; i<n; i++){
        ep.push_back({v[i][2]+v[i][0], i});
        ep.push_back({v[i][2]-v[i][0], i});
    }
    sort(ep.begin(), ep.end());
    vector<vector<int>> fts(n);
    for (int i=0; i<2*n; i++){
        //cout << ep[i].first << " " << ep[i].second << "\n";
        fts[ep[i].second].push_back(i);
    }

    set<int> todo;
    for (int i=0; i<n; i++) todo.insert(i);
    vector<int> done(n, 0);
    while (!todo.empty()){
        int cur = *todo.begin();
        if (n <= 5000){
            for (int i=0; i<n; i++){
                if (!done[v[i][1]] && dist(v[cur][2], v[cur][3], v[i][2], v[i][3]) < eps+(double) (0-(v[cur][0]+v[i][0]))){
                    done[v[i][1]] = v[cur][1]+1;
                    todo.erase(i);
                }
            }
        }
        else {
            //cout << cur << "\n";
            int l = fts[cur][0], r = fts[cur][1];
            while (l > 0 && ep[l-1].first == ep[l].first) l--;
            while (r < 2*n-1 && ep[r+1].first == ep[r].first) r++;
            //cout << l << " " << r << "\n";
            for (int i=l; i<=r; i++){
                if (!done[ep[i].second]){
                    done[ep[i].second] = v[cur][1]+1;
                    todo.erase(ep[i].second);
                }
            }
        }
    }
    if (n <= 5000) for (int i=0; i<n; i++) cout << done[i] << "\n";
    else {
        vector<int> w(n);
        for (int i=0; i<n; i++) w[v[i][1]] = i;
        for (int i=0; i<n; i++) cout << done[w[i]] << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 432 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 7 ms 1372 KB Output is correct
20 Correct 7 ms 1284 KB Output is correct
21 Correct 7 ms 1372 KB Output is correct
22 Correct 91 ms 1428 KB Output is correct
23 Correct 76 ms 1372 KB Output is correct
24 Correct 80 ms 1372 KB Output is correct
25 Correct 83 ms 1444 KB Output is correct
26 Correct 78 ms 1432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 526 ms 61872 KB Output is correct
2 Correct 536 ms 61848 KB Output is correct
3 Correct 520 ms 61688 KB Output is correct
4 Correct 502 ms 62124 KB Output is correct
5 Correct 482 ms 59612 KB Output is correct
6 Correct 469 ms 59820 KB Output is correct
7 Correct 450 ms 59772 KB Output is correct
8 Correct 462 ms 59792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 171 ms 21196 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 550 ms 62640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 432 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 7 ms 1372 KB Output is correct
20 Correct 7 ms 1284 KB Output is correct
21 Correct 7 ms 1372 KB Output is correct
22 Correct 91 ms 1428 KB Output is correct
23 Correct 76 ms 1372 KB Output is correct
24 Correct 80 ms 1372 KB Output is correct
25 Correct 83 ms 1444 KB Output is correct
26 Correct 78 ms 1432 KB Output is correct
27 Incorrect 14 ms 2472 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 432 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 7 ms 1372 KB Output is correct
20 Correct 7 ms 1284 KB Output is correct
21 Correct 7 ms 1372 KB Output is correct
22 Correct 91 ms 1428 KB Output is correct
23 Correct 76 ms 1372 KB Output is correct
24 Correct 80 ms 1372 KB Output is correct
25 Correct 83 ms 1444 KB Output is correct
26 Correct 78 ms 1432 KB Output is correct
27 Correct 526 ms 61872 KB Output is correct
28 Correct 536 ms 61848 KB Output is correct
29 Correct 520 ms 61688 KB Output is correct
30 Correct 502 ms 62124 KB Output is correct
31 Correct 482 ms 59612 KB Output is correct
32 Correct 469 ms 59820 KB Output is correct
33 Correct 450 ms 59772 KB Output is correct
34 Correct 462 ms 59792 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Incorrect 171 ms 21196 KB Output isn't correct
37 Halted 0 ms 0 KB -