結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
![]() |
提出日時 | 2024-03-02 14:09:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 1,031 bytes |
コンパイル時間 | 2,328 ms |
コンパイル使用メモリ | 205,596 KB |
最終ジャッジ日時 | 2025-02-19 23:31:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, a, b) for(ll i = a; i < b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) constexpr ll inf = 4e18; struct SetupIO { SetupIO() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(30); } } setup_io; int main(void) { int n; cin >> n; vector<ll> x(n), y(n); rep(i, 0, n) { cin >> x[i] >> y[i]; } vector<pair<ll, P>> v; rep(i, 0, n) { rep(j, i + 1, n) { v.push_back({(x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]), {i, j}}); } } sort(v.begin(), v.end()); vector<bool> flag(n); ll ans = 0; for(const auto& p : v) { if(flag[p.second.first] or flag[p.second.second]) continue; if(p.second.first == 0) { ans++; } else { flag[p.second.first] = true; } flag[p.second.second] = true; } cout << ans << '\n'; }