Submission #399768

# Submission time Handle Problem Language Result Execution time Memory
399768 2021-05-06T15:03:00 Z my99n Circle selection (APIO18_circle_selection) C++14
0 / 100
7 ms 1104 KB
#include<bits/stdc++.h>
using namespace std;

typedef pair<double,double> point;

struct A {
  double x, y, r;
  int i;
  bool operator < (const A & o) const {
    if (r == o.r) return i < o.i;
    return r > o.r;
  }
} cir[5050];
int ans[5010];
int mark[5010];

double dis (point i, point j) {
  double temp = (i.first - j.first) * (i.first - j.first) + (i.second - j.second) * (i.second - j.second);
  return sqrt(temp);
}

bool intersect (A i, A j) {
  return (dis({i.x, i.y}, {j.x, j.y}) <= i.r+j.r);
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  for (int i = 1; i <= n; i++) {
    double x, y, r; cin >> x >> y >> r;
    cir[i] = {x, y, r, i};
  }
  sort(cir+1, cir+1+n);
  for (int i = 1; i <= n; i++) {
    int ind = cir[i].i;
    cerr << ind << endl;
    if (mark[ind]) continue;
    mark[ind] = 1;
    ans[ind] = ind;
    for (int j = i+1; j <= n; j++) {
      int anind = cir[j].i;
      if (intersect(cir[i], cir[j])) {
        ans[anind] = ind;
        mark[anind] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 7 ms 1104 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 716 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Halted 0 ms 0 KB -