結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2020-10-23 22:48:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 260 ms / 2,000 ms |
コード長 | 1,148 bytes |
コンパイル時間 | 1,937 ms |
コンパイル使用メモリ | 178,388 KB |
実行使用メモリ | 15,840 KB |
最終ジャッジ日時 | 2024-07-21 11:51:18 |
合計ジャッジ時間 | 5,626 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#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 1000000007ll 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;}