結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
![]() |
提出日時 | 2020-10-23 23:02:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 130 ms / 2,000 ms |
コード長 | 1,137 bytes |
コンパイル時間 | 1,854 ms |
コンパイル使用メモリ | 177,420 KB |
実行使用メモリ | 11,744 KB |
最終ジャッジ日時 | 2024-07-21 12:12:31 |
合計ジャッジ時間 | 4,180 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#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; }