結果

問題 No.1265 Balloon Survival
ユーザー ocvret_ocvret_
提出日時 2020-10-23 22:48:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 176,896 KB
実行使用メモリ 17,048 KB
最終ジャッジ日時 2023-09-28 17:10:23
合計ジャッジ時間 6,532 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 16 ms
4,740 KB
testcase_15 AC 13 ms
4,988 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 110 ms
17,048 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 16 ms
4,864 KB
testcase_21 AC 39 ms
7,232 KB
testcase_22 AC 24 ms
6,164 KB
testcase_23 AC 26 ms
6,256 KB
testcase_24 AC 256 ms
15,636 KB
testcase_25 AC 251 ms
16,852 KB
testcase_26 AC 254 ms
16,504 KB
testcase_27 AC 267 ms
16,472 KB
testcase_28 AC 263 ms
16,700 KB
testcase_29 AC 253 ms
15,496 KB
testcase_30 AC 259 ms
15,836 KB
testcase_31 AC 267 ms
15,632 KB
testcase_32 AC 258 ms
16,484 KB
testcase_33 AC 261 ms
15,752 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

ll pp(ll k){return k*k;}
ll d2(pair<ll,ll> a,pair<ll,ll> b){
  return pp(a.first-b.first)+pp(a.second-b.second);
}
struct info{
  ll dist,a,b;
  bool operator<(const info& o)const{return dist < o.dist;}
  bool operator>(const info& o)const{return dist > o.dist;}
};

int main(){
  
  int n;
  cin >> n;
  vector<pair<ll,ll>> v(n);
  rep(i,n)cin >> v[i].first >> v[i].second;
  priority_queue<info,vector<info>,greater<info>> que;
  rep(i,n)for(int j = i+1;j < n;j++){
    que.push(info{d2(v[i],v[j]),i,j});
  }
  set<int> era;
  int res = 0;
  while(!que.empty()){
    info k = que.top();que.pop();
    if(era.count(k.a) || era.count(k.b))continue;
    if(k.dist < d2(v[0],v[k.a]) && k.dist < d2(v[0],v[k.b])){
      era.insert(k.a);
      era.insert(k.b);
    }
    if(k.a == 0){
      era.insert(k.b);
      res++;
    }
  }
  cout << res << "\n";


  return 0;
}
0