Submission #399767

# Submission time Handle Problem Language Result Execution time Memory
399767 2021-05-06T15:02:25 Z my99n Circle selection (APIO18_circle_selection) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

typedef point pair<double,double>

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;
}

Compilation message

circle_selection.cpp:4:9: error: 'point' does not name a type
    4 | typedef point pair<double,double>
      |         ^~~~~
circle_selection.cpp:13:3: error: 'cir' does not name a type
   13 | } cir[5050];
      |   ^~~
circle_selection.cpp:17:13: error: 'point' was not declared in this scope
   17 | double dis (point i, point j) {
      |             ^~~~~
circle_selection.cpp:17:22: error: 'point' was not declared in this scope
   17 | double dis (point i, point j) {
      |                      ^~~~~
circle_selection.cpp:17:29: error: expression list treated as compound expression in initializer [-fpermissive]
   17 | double dis (point i, point j) {
      |                             ^
circle_selection.cpp:22:17: error: 'A' was not declared in this scope
   22 | bool intersect (A i, A j) {
      |                 ^
circle_selection.cpp:22:22: error: 'A' was not declared in this scope
   22 | bool intersect (A i, A j) {
      |                      ^
circle_selection.cpp:22:25: error: expression list treated as compound expression in initializer [-fpermissive]
   22 | bool intersect (A i, A j) {
      |                         ^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:32:5: error: 'cir' was not declared in this scope
   32 |     cir[i] = {x, y, r, i};
      |     ^~~
circle_selection.cpp:34:8: error: 'cir' was not declared in this scope
   34 |   sort(cir+1, cir+1+n);
      |        ^~~
circle_selection.cpp:43:35: error: 'intersect' cannot be used as a function
   43 |       if (intersect(cir[i], cir[j])) {
      |                                   ^