結果

問題 No.1265 Balloon Survival
ユーザー tyonbokuntyonbokun
提出日時 2020-10-24 00:20:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,612 bytes
コンパイル時間 1,123 ms
コンパイル使用メモリ 115,132 KB
実行使用メモリ 13,016 KB
最終ジャッジ日時 2023-09-28 19:31:48
合計ジャッジ時間 3,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 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,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 12 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 56 ms
11,784 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 12 ms
4,380 KB
testcase_21 AC 26 ms
5,248 KB
testcase_22 AC 17 ms
5,080 KB
testcase_23 AC 18 ms
4,944 KB
testcase_24 AC 112 ms
12,108 KB
testcase_25 AC 114 ms
12,612 KB
testcase_26 AC 114 ms
11,332 KB
testcase_27 AC 114 ms
11,776 KB
testcase_28 AC 115 ms
11,428 KB
testcase_29 AC 116 ms
12,668 KB
testcase_30 AC 114 ms
12,072 KB
testcase_31 AC 113 ms
12,896 KB
testcase_32 AC 113 ms
13,016 KB
testcase_33 AC 113 ms
12,428 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using ll = long long;
using vll = std::vector<ll>;
using namespace std;
#define REP(i, x, n) for(int i = x; i < (n); i++)
#define rep(i, n) REP(i, 0, n)
const ll MOD = 1000000007;
template<class T> void gi(T &x){
  int minus=0; x=0; char c=getchar();
  for(;c<'0'||c>'9'; c=getchar()) minus|=(c=='-');
  for(;c>='0'&&c<='9'; c=getchar()) x=(x<<1)+(x<<3)+(c^48);
  if(minus) x=-x;
}
int main() {
  int n; gi(n);
  vector<pair<ll,ll>> xy;
  rep(i,n){
    ll x,y; gi(x);gi(y);
    xy.push_back({x,y});
  }
  vector<bool> chk(n);
  auto getD = [&](vector<pair<ll,ll>>& vec, int id1, int id2){
    return (vec[id1].first-vec[id2].first)*(vec[id1].first-vec[id2].first)
      +(vec[id1].second-vec[id2].second)*(vec[id1].second-vec[id2].second);
  };
  struct D{
    ll d; int x; int y;
  };
  auto cmpD = [](D& l, D& r){
    return l.d > r.d;
  };
  priority_queue<D,vector<D>,decltype(cmpD)> q{cmpD};
  REP(i,0,n)REP(j,i+1,n){
    q.push({getD(xy,i,j),i,j});
  }
  int ans = 0;
  while(!q.empty()){
    D target = q.top(); q.pop();
    if(target.x == 0){
      if(chk[target.y] == false){
        ans++;
        chk[target.y] = true;
      }
    }
    else if(chk[target.x] || chk[target.y]){
    }else{
      chk[target.x] = true;
      chk[target.y] = true;
    }
  }
  printf( "%d\n", ans );
  
  return 0;
}
0