結果

問題 No.1265 Balloon Survival
ユーザー umezoumezo
提出日時 2020-10-23 23:18:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 942 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 218,432 KB
実行使用メモリ 46,332 KB
最終ジャッジ日時 2023-09-28 18:31:36
合計ジャッジ時間 14,064 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 50 ms
8,156 KB
testcase_15 AC 34 ms
6,900 KB
testcase_16 AC 11 ms
4,872 KB
testcase_17 AC 453 ms
27,596 KB
testcase_18 AC 17 ms
5,416 KB
testcase_19 AC 12 ms
4,996 KB
testcase_20 AC 49 ms
8,196 KB
testcase_21 AC 150 ms
14,308 KB
testcase_22 AC 71 ms
9,932 KB
testcase_23 AC 85 ms
10,480 KB
testcase_24 AC 889 ms
46,176 KB
testcase_25 AC 928 ms
46,040 KB
testcase_26 AC 933 ms
45,952 KB
testcase_27 AC 916 ms
46,108 KB
testcase_28 AC 892 ms
46,332 KB
testcase_29 AC 904 ms
45,916 KB
testcase_30 AC 942 ms
46,256 KB
testcase_31 AC 934 ms
46,024 KB
testcase_32 AC 925 ms
46,216 KB
testcase_33 AC 923 ms
45,940 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int INF=1e9+7;

int main(){
  int n;
  cin>>n;
  
  vector<ll> X(n),Y(n);
  rep(i,n) cin>>X[i]>>Y[i];
  
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  if(n==2){
    cout<<1<<endl;
    return 0;
  }
  
  vector<vector<ll>> A(n,vector<ll>(n));
  vector<ll> B;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      A[i][j]=(X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]);
      B.push_back(A[i][j]);
    }
  }
  sort(ALL(B));
  B.erase(unique(ALL(B)),B.end());
  set<tuple<int,int,int>> s;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      A[i][j]=lower_bound(ALL(B),A[i][j])-B.begin();
      s.insert({A[i][j],i,j});
    }
  }
  vector<int> D(1010,1);
  int rem=n;
  int cnt=0;
  for(auto x:s){
    if(rem==1) break;
    else if(rem==2){
      cnt++;
      break;
    }
    int a=get<1>(x);
    int b=get<2>(x);
    int c=get<0>(x);
    if(D[a]==0 || D[b]==0) continue;
    else if(a==0 && D[b]==1){
      D[b]=0;
      rem--;
      cnt++;
      continue;
    }
    else{
      D[a]=0,D[b]=0;
      rem-=2;
    }
  }
  cout<<cnt<<endl;

  return 0;
}
0