답안 #734842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734842 2023-05-03T07:06:45 Z keisuke6 원 고르기 (APIO18_circle_selection) C++14
23 / 100
2391 ms 289064 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> X(N),Y(N),R(N);
  for(int i=0;i<N;i++){
    cin>>X[i]>>Y[i]>>R[i];
    X[i] += (int)(1e9)+2*R[i];
    Y[i] += (int)(1e9)+2*R[i];
  }
  vector<int> A(N,N+1);
  vector<pair<int,int>> S(N);
  for(int i=0;i<N;i++) S[i] = {R[i],N-1-i};
  sort(S.rbegin(),S.rend());
  int n = ((int)(2e18)/(2*R[0]))+10;
  map<int,set<int>> m;
  vector<int> I(N);
  for(int i=0;i<N;i++){
    m[X[i]/(2*R[0])*n+Y[i]/(2*R[i])].insert(i);
    I[i] = X[i]/(2*R[0])*n+Y[i]/(2*R[i]);
  }
  for(int i=0;i<N;i++){
    int ind = N-1-S[i].second;
    if(A[ind] != N+1) continue;
    int pos = I[ind];
    vector<int> T = {};
    for(int x:m[pos]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos+1]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos-1]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos+n]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos+n+1]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos+n-1]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos-n]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos-n+1]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int x:m[pos-n-1]){
      if((X[ind]-X[x])*(X[ind]-X[x])+(Y[ind]-Y[x])*(Y[ind]-Y[x]) <= (R[ind]+R[x])*(R[ind]+R[x])){
        T.push_back(x);
        A[x] = ind+1;
      }
    }
    for(int y:T) m[I[y]].erase(y);
  }
  for(int i=0;i<N;i++) cout<<A[i]<<' ';
  cout<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 260 KB Output is correct
4 Incorrect 1 ms 296 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 516 ms 33680 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 Correct 2141 ms 286296 KB Output is correct
2 Correct 2391 ms 288852 KB Output is correct
3 Correct 807 ms 36824 KB Output is correct
4 Correct 2293 ms 288832 KB Output is correct
5 Correct 2233 ms 289064 KB Output is correct
6 Correct 710 ms 34708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 260 KB Output is correct
4 Incorrect 1 ms 296 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 260 KB Output is correct
4 Incorrect 1 ms 296 KB Output isn't correct
5 Halted 0 ms 0 KB -