結果

問題 No.1265 Balloon Survival
ユーザー butsurizukibutsurizuki
提出日時 2020-10-23 22:26:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 3,909 ms
コンパイル使用メモリ 176,020 KB
実行使用メモリ 13,028 KB
最終ジャッジ日時 2023-09-28 16:25:23
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 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 1 ms
4,380 KB
testcase_06 AC 1 ms
4,504 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 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 7 ms
4,384 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 37 ms
11,952 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 18 ms
5,116 KB
testcase_22 AC 12 ms
5,124 KB
testcase_23 AC 13 ms
5,076 KB
testcase_24 AC 66 ms
12,196 KB
testcase_25 AC 66 ms
12,196 KB
testcase_26 AC 67 ms
12,584 KB
testcase_27 AC 66 ms
11,972 KB
testcase_28 AC 66 ms
11,328 KB
testcase_29 AC 66 ms
13,028 KB
testcase_30 AC 67 ms
11,584 KB
testcase_31 AC 66 ms
11,336 KB
testcase_32 AC 66 ms
11,456 KB
testcase_33 AC 65 ms
12,524 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int main(){
  vector<pair<long long,pair<int,int>>> vc;
  int n;
  cin >> n;
  vector<long long> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      long long cost=0;
      cost+=(a[i]-a[j])*(a[i]-a[j]);
      cost+=(b[i]-b[j])*(b[i]-b[j]);
      vc.push_back(make_pair(cost,make_pair(i,j)));
    }
  }
  sort(vc.begin(),vc.end());
  int cnt=vc.size(),res=0;
  vector<int> fl(n,0);
  for(int i=0;i<cnt;i++){
    pair<int,int> conf=vc[i].second;
    int p=conf.first,q=conf.second;
    if(fl[p]==1 || fl[q]==1){continue;}
    //cout << p << q << '\n';
    if(p==0){res++;fl[q]=1;continue;}
    fl[p]=1;fl[q]=1;
  }
  cout << res << '\n';
  return 0;
}
0