結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2020-10-23 22:10:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 1,147 bytes |
コンパイル時間 | 2,632 ms |
コンパイル使用メモリ | 204,472 KB |
最終ジャッジ日時 | 2025-01-15 13:09:33 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;} template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;} #define all(x) (x).begin(),(x).end() #define debug(x) cerr << #x << " = " << (x) << endl; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vec<ll> X(N),Y(N); for(int i=0;i<N;i++){ cin >> X[i] >> Y[i]; } vec<int> removed(N); vec<pair<ll,pair<int,int>>> ev; for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){ ll dx = X[i]-X[j],dy = Y[i]-Y[j]; ev.push_back({dx*dx+dy*dy,{i,j}}); } sort(all(ev)); int ans = 0; for(auto& [d,p]:ev){ auto [a,b] = p; if(a){ if(!removed[a] && !removed[b]){ removed[a] = removed[b] = 1; } }else{ if(!removed[b]){ ans++; removed[b] = 1; } } } cout << ans << "\n"; }