Submission #658745

# Submission time Handle Problem Language Result Execution time Memory
658745 2022-11-14T20:01:51 Z 600Mihnea Circle selection (APIO18_circle_selection) C++17
0 / 100
1 ms 212 KB
bool home = 1;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 3e5 + 7;
int n;

struct Circle {
  int x;
  int y;
  int r;
};

bool doIntersect(Circle a, Circle b) {
  /// dist <= a.r + b.r
  /// dist ^  2 <= (a.r + b.r) ^ 2
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) <= (a.r + b.r) * (a.r + b.r);
}

Circle circles[N];
int ret[N];

int main() {
  if (home == 0) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  } else {
    freopen ("input.txt", "r", stdin);
  }

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> circles[i].x >> circles[i].y >> circles[i].r;
  }

  vector<int> inds(n);
  iota(inds.begin(), inds.end(), 1);

  while ((int) inds.size() >= 1) {
    int best = inds[0];
    for (auto &ind : inds) {
      if (circles[ind].r > circles[best].r || (circles[ind].r == circles[best].r && ind < best)) {
        best = ind;
      }
    }
    vector<int> newInds;
    for (auto &ind : inds) {
      if (doIntersect(circles[ind], circles[best])) {
        ret[ind] = best;
      } else {
        newInds.push_back(ind);
      }
    }
    inds = newInds;
  }

  for (int i = 1; i <= n; i++) {
    cout << ret[i] << " ";
  }
  cout << "\n";

  return 0;
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:31:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen ("input.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -