Submission #815630

# Submission time Handle Problem Language Result Execution time Memory
815630 2023-08-08T17:36:28 Z Ozy Circle selection (APIO18_circle_selection) C++17
7 / 100
79 ms 1752 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a <<  " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli> 

#define MAX 5000
//para el vector de orden
#define id second

struct x {
    lli x;
    lli y;
    lli r;
};

lli n;
lli res[MAX+2],vis[MAX+2];
x circulo[MAX+2];
vector<pll> orden;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    rep(i,1,n) {
        cin >> circulo[i].x >> circulo[i].y >> circulo[i].r;
        orden.push_back({-circulo[i].r, i});
    }
    sort(orden.begin(), orden.end());

    for (auto yo : orden) {
        for(auto otro : orden) {

            if (vis[otro.id]) continue;
            if (otro.id == yo.id) {
                res[yo.id] = yo.id;
                break;
            }

            lli a = circulo[yo.id].x - circulo[otro.id].x;
            lli b = circulo[yo.id].y - circulo[otro.id].y;
            a *= a;
            b *= b;
            lli c = circulo[yo.id].r + circulo[otro.id].r;
            c *= c;

            if (c >= (a+b)) {
                res[yo.id] = otro.id;
                vis[yo.id] = 1;
                break;
            } 
        }
    }

    rep(i,1,n) cout << res[i] << ' ';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 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 340 KB Output is correct
19 Correct 4 ms 852 KB Output is correct
20 Correct 2 ms 852 KB Output is correct
21 Correct 4 ms 844 KB Output is correct
22 Correct 28 ms 816 KB Output is correct
23 Correct 33 ms 832 KB Output is correct
24 Correct 32 ms 828 KB Output is correct
25 Correct 27 ms 816 KB Output is correct
26 Correct 27 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1752 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Runtime error 79 ms 1400 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1752 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 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 340 KB Output is correct
19 Correct 4 ms 852 KB Output is correct
20 Correct 2 ms 852 KB Output is correct
21 Correct 4 ms 844 KB Output is correct
22 Correct 28 ms 816 KB Output is correct
23 Correct 33 ms 832 KB Output is correct
24 Correct 32 ms 828 KB Output is correct
25 Correct 27 ms 816 KB Output is correct
26 Correct 27 ms 820 KB Output is correct
27 Runtime error 5 ms 1700 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 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 340 KB Output is correct
19 Correct 4 ms 852 KB Output is correct
20 Correct 2 ms 852 KB Output is correct
21 Correct 4 ms 844 KB Output is correct
22 Correct 28 ms 816 KB Output is correct
23 Correct 33 ms 832 KB Output is correct
24 Correct 32 ms 828 KB Output is correct
25 Correct 27 ms 816 KB Output is correct
26 Correct 27 ms 820 KB Output is correct
27 Runtime error 4 ms 1752 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -