답안 #701390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701390 2023-02-21T07:17:19 Z Abrar_Al_Samit 원 고르기 (APIO18_circle_selection) C++17
0 / 100
602 ms 28596 KB
#include<bits/stdc++.h>
using namespace std;

long long sqrd(int x) {
  return x * 1LL * x;
}
struct circle {
  int x, y, r, j;

  bool operator< (const circle& b) const {
    if(r!=b.r) return r > b.r;
    return j < b.j;
  }

  bool intersect(const circle& b) const {
    return sqrd(x-b.x) + sqrd(y-b.y) <= sqrd(r+b.r);
  }
};

bool cmp(circle a, circle b) {
  return make_pair(a.x, a.r) < make_pair(b.x, b.r);
}
void PlayGround() {
  int n;
  cin>>n;

  set<circle>s;
  for(int i=0; i<n; ++i) {
    int x, y, r;
    cin>>x>>y>>r;

    circle z = {x, y, r, i+1};
    s.insert(z);
  }

  int at[n+1];
  vector<circle>order;
  for(auto z : s) {
    order.push_back(z);
  }
  sort(order.begin(), order.end(), cmp);

  for(int i=0; i<n; ++i) {
    at[order[i].j] = i;
  }

  bool done[n+1] = {0};

  int ans[n+1];
  while(!s.empty()) {
    auto cur = *s.begin();
    s.erase(cur);

    int p = at[cur.j];
    while(p>=0 && !done[p] && cur.intersect(order[p])) {
      done[p] = true;
      ans[order[p].j] = cur.j;
      s.erase(order[p]);
      --p;
    }
    p = at[cur.j] + 1;
    while(p<n && !done[p] && cur.intersect(order[p])) {
      done[p] = true;
      ans[order[p].j] = cur.j;
      s.erase(order[p]);
      ++p;
    }
  }
  for(int i=1; i<=n; ++i) {
    cout<<ans[i]<<' ';
  }


  // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 602 ms 28596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 292 ms 28564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -