結果
問題 | No.1265 Balloon Survival |
ユーザー | shinchan |
提出日時 | 2020-10-23 22:17:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,098 ms / 2,000 ms |
コード長 | 1,167 bytes |
コンパイル時間 | 2,228 ms |
コンパイル使用メモリ | 200,028 KB |
最終ジャッジ日時 | 2025-01-15 13:16:56 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) typedef long long ll; using namespace std; const ll mod=1000000007, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; ll calc(ll x, ll y){return x*x + y*y;} int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); ll n, a, b; cin >> n; bool burst[n]; memset(burst, 0, sizeof(burst)); vector<pair<ll, ll> > v; multiset<pair<ll, pair<int, int> > > ms; for(int i=0;i<n;i++){ cin >> a >> b; v.push_back({a, b}); } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i == j) continue; ms.insert({calc(v[i].first - v[j].first, v[i].second - v[j].second), {i, j}}); } } int ans = 0; while(!ms.empty()){ auto itr = ms.begin(); int id1 = itr->second.first; int id2 = itr->second.second; ms.erase(itr); if(burst[id1] || burst[id2]) continue; if(id1 > id2) swap(id1, id2); if(id1 == 0){ burst[id2] = true; ans++; }else{ burst[id1] = burst[id2] = true; } } cout << ans << endl; return 0; }