Submission #658175

# Submission time Handle Problem Language Result Execution time Memory
658175 2022-11-12T10:35:14 Z Richem Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 21136 KB
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <vector>
#define int long long

using namespace std;

const int MAX_CERCLE = 3e5+42, INF = 1e9;

struct Cercle{
    int xCentre, yCentre, rayon, id;

    bool operator<(Cercle autre) {
        if(rayon == autre.rayon)
            return id < autre.id;
        return rayon > autre.rayon;
    }

    bool intersecte(Cercle autre) {
        int xDist = xCentre - autre.xCentre, yDist = yCentre - autre.yCentre;
        int rDist = rayon + autre.rayon;

        return xDist * xDist + yDist * yDist <= rDist * rDist;
    }
};

int nbCercle;
Cercle cercle[MAX_CERCLE];

void input() {
    cin >> nbCercle;

    for(int idCercle = 0; idCercle < nbCercle; idCercle++) {
        cin >> cercle[idCercle].xCentre >> cercle[idCercle].yCentre >> cercle[idCercle].rayon;
        cercle[idCercle].id = idCercle;
    }
    sort(cercle, cercle + nbCercle);
}

bool enleve[MAX_CERCLE] = {0};
int quiEnleve[MAX_CERCLE];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    input();

    for(int grand = 0; grand < nbCercle; grand++) {
        if(enleve[grand])
            continue;

        for(int autre = 0; autre < nbCercle; autre++) {
            if(cercle[grand].intersecte(cercle[autre]) && !enleve[autre]) {
                enleve[autre] = 1;
                quiEnleve[cercle[autre].id] = cercle[grand].id;
            } 
        }
    }

    for(int i = 0; i < nbCercle; i++) {
        cout << quiEnleve[i]+1 << " ";
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 224 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 380 KB Output is correct
19 Correct 3 ms 728 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 31 ms 592 KB Output is correct
23 Correct 38 ms 656 KB Output is correct
24 Correct 30 ms 684 KB Output is correct
25 Correct 41 ms 596 KB Output is correct
26 Correct 44 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 14412 KB Output is correct
2 Correct 130 ms 14408 KB Output is correct
3 Correct 141 ms 20824 KB Output is correct
4 Correct 119 ms 21136 KB Output is correct
5 Execution timed out 3037 ms 16968 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 3096 ms 4320 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3096 ms 9808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 224 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 380 KB Output is correct
19 Correct 3 ms 728 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 31 ms 592 KB Output is correct
23 Correct 38 ms 656 KB Output is correct
24 Correct 30 ms 684 KB Output is correct
25 Correct 41 ms 596 KB Output is correct
26 Correct 44 ms 596 KB Output is correct
27 Correct 5 ms 1108 KB Output is correct
28 Correct 5 ms 976 KB Output is correct
29 Correct 5 ms 1004 KB Output is correct
30 Correct 114 ms 980 KB Output is correct
31 Correct 127 ms 980 KB Output is correct
32 Correct 122 ms 988 KB Output is correct
33 Correct 49 ms 7976 KB Output is correct
34 Correct 44 ms 8012 KB Output is correct
35 Correct 70 ms 7796 KB Output is correct
36 Execution timed out 3080 ms 6824 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 224 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 380 KB Output is correct
19 Correct 3 ms 728 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 31 ms 592 KB Output is correct
23 Correct 38 ms 656 KB Output is correct
24 Correct 30 ms 684 KB Output is correct
25 Correct 41 ms 596 KB Output is correct
26 Correct 44 ms 596 KB Output is correct
27 Correct 119 ms 14412 KB Output is correct
28 Correct 130 ms 14408 KB Output is correct
29 Correct 141 ms 20824 KB Output is correct
30 Correct 119 ms 21136 KB Output is correct
31 Execution timed out 3037 ms 16968 KB Time limit exceeded
32 Halted 0 ms 0 KB -