Submission #265486

# Submission time Handle Problem Language Result Execution time Memory
265486 2020-08-14T22:08:39 Z DS007 Circle selection (APIO18_circle_selection) C++14
0 / 100
3000 ms 9752 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
struct circle {
    int x, y, r, i;
 
    bool operator < (circle c) {
        if (r == c.r)
            return i < c.i;
        return r > c.r;
    }
};
 
const int N = 3e5;
circle c[N];
bool done[N];
int n, ans[N];
 
int solveTestCase() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> c[i].x >> c[i].y >> c[i].r, c[i].i = i + 1;
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (c[j] < c[j + 1]) {
                circle temp = c[j];
                c[j] = c[j + 1];
                c[j + 1] = temp;
            }
        }
    }
 
    for (int i = 0; i < n; i++) {
        if (done[i])
            continue;
 
        ans[c[i].i] = c[i].i;
        for (int j = i + 1; j < n; j++) {
            int dist = (c[i].y - c[j].y) * (c[i].y - c[j].y) + (c[i].x - c[j].x) * (c[i].x - c[j].x);
            if (dist <= (c[i].r + c[j].r) * (c[i].r + c[j].r))
                done[j] = true, ans[c[j].i] = c[i].i;
        }
    }
 
    for (int i = 1; i <= n; i++)
        cout << ans[i] << " ";
}
 
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    int t = 1;
    //cin >> t;
    while (t--)
        solveTestCase();
}
 

Compilation message

circle_selection.cpp: In function 'long long int solveTestCase()':
circle_selection.cpp:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 130 ms 3724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 9720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 118 ms 3704 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 9752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 130 ms 3724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 130 ms 3724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -