답안 #701408

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

const int nax = 3e5 + 3;
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);
  }
} bag[nax];

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<pair<int,int>>b, c;
  set<pair<int,int>,greater<pair<int,int>>>a;
  for(int i=0; i<n; ++i) {
    int x, y, r;
    cin>>x>>y>>r;

    bag[i] = {x, y, r, i+1};

    a.insert({2*r, n-i});
    b.insert({x-r, i});
    c.insert({x+r, i});
  }

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

    //cerr<<n-x.second<<endl;

    circle cur = bag[n-x.second];

    vector<int>cache;

    while(1) {
      auto it = b.lower_bound(make_pair(cur.x-cur.r, 0));
      if(it==b.end() || it->first>cur.x+cur.r) break;

      cache.push_back(it->second);
      circle rem = bag[it->second];
      b.erase(make_pair(rem.x-rem.r, rem.j-1));
      c.erase(make_pair(rem.x+rem.r, rem.j-1));
    }

    while(1) {
      auto it = c.lower_bound(make_pair(cur.x-cur.r, 0));
      if(it==c.end() || it->first>cur.x+cur.r) break;

      cache.push_back(it->second);
      circle rem = bag[it->second];
      b.erase(make_pair(rem.x-rem.r, rem.j-1));
      c.erase(make_pair(rem.x+rem.r, rem.j-1));
    }

    for(int x : cache) {
      ans[x+1] = cur.j;
      a.erase(make_pair(2 * bag[x].r, n-x));
    }
  }
  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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1358 ms 50684 KB Output is correct
2 Correct 1299 ms 50696 KB Output is correct
3 Correct 1292 ms 50620 KB Output is correct
4 Correct 1364 ms 50616 KB Output is correct
5 Correct 978 ms 50236 KB Output is correct
6 Correct 1022 ms 54992 KB Output is correct
7 Correct 1055 ms 55244 KB Output is correct
8 Correct 1069 ms 55040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 879 ms 50008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -