結果

問題 No.1265 Balloon Survival
ユーザー ocvret_ocvret_
提出日時 2020-10-23 22:41:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,314 bytes
コンパイル時間 1,847 ms
コンパイル使用メモリ 176,360 KB
実行使用メモリ 16,728 KB
最終ジャッジ日時 2023-09-28 16:53:12
合計ジャッジ時間 6,220 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
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 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 13 ms
4,740 KB
testcase_16 WA -
testcase_17 AC 114 ms
16,628 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 16 ms
4,688 KB
testcase_21 AC 41 ms
6,188 KB
testcase_22 AC 24 ms
6,484 KB
testcase_23 AC 27 ms
6,484 KB
testcase_24 AC 268 ms
15,704 KB
testcase_25 AC 275 ms
15,920 KB
testcase_26 AC 278 ms
15,780 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 270 ms
16,728 KB
testcase_30 AC 276 ms
15,944 KB
testcase_31 AC 271 ms
15,504 KB
testcase_32 WA -
testcase_33 AC 262 ms
16,024 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 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);
    }else if(k.dist >= d2(v[0],v[k.a])){
      era.insert(k.a);
      res++;
    }else if(k.dist < d2(v[0],v[k.b])){
      era.insert(k.b);
      res++;
    }else{
      era.insert(k.a);
      era.insert(k.b);
      res += 2;
    }
  }
  cout << res << "\n";


  return 0;
}
0