結果

問題 No.1265 Balloon Survival
ユーザー どららどらら
提出日時 2020-10-23 23:02:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,137 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 175,816 KB
実行使用メモリ 13,120 KB
最終ジャッジ日時 2023-09-28 17:33:45
合計ジャッジ時間 5,185 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 10 ms
4,384 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 61 ms
11,892 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 23 ms
5,260 KB
testcase_22 AC 14 ms
5,260 KB
testcase_23 AC 16 ms
5,276 KB
testcase_24 AC 157 ms
13,120 KB
testcase_25 AC 155 ms
11,920 KB
testcase_26 AC 166 ms
12,712 KB
testcase_27 AC 169 ms
11,860 KB
testcase_28 AC 160 ms
12,608 KB
testcase_29 AC 163 ms
12,472 KB
testcase_30 AC 160 ms
11,908 KB
testcase_31 AC 150 ms
12,004 KB
testcase_32 AC 162 ms
11,980 KB
testcase_33 AC 157 ms
12,104 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll t2;
  int i, j;
};
bool operator<(const ST& a, const ST& b){
  return a.t2 > b.t2;
}


int main(){
  int N;
  cin >> N;
  vector<pair<ll,ll>> v;
  rep(i,N){
    ll x, y;
    cin >> x >> y;
    v.emplace_back(x,y);
  }

  priority_queue<ST> que;
  rep(i,N){
    REP(j,i+1,N){
      ll t2 = (v[i].first-v[j].first)*(v[i].first-v[j].first) +
        (v[i].second-v[j].second)*(v[i].second-v[j].second);
      que.push((ST){t2,i,j});
    }
  }

  int ret = 0;
  vector<bool> enable(N, true);
  while(!que.empty()){
    ST st = que.top(); que.pop();
    
    if(st.i == 0){
      if(enable[st.j]){
        ret++;
        enable[st.j] = false;
      }
    } else {
      if(enable[st.i] && enable[st.j]){
        enable[st.i] = false;
        enable[st.j] = false;
      }
    }
  }

  cout << ret << endl;
  
  return 0;
}

0