結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
|
提出日時 | 2025-09-28 11:34:41 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 689 ms / 2,000 ms |
コード長 | 1,232 bytes |
コンパイル時間 | 3,201 ms |
コンパイル使用メモリ | 295,220 KB |
実行使用メモリ | 19,560 KB |
最終ジャッジ日時 | 2025-09-28 11:34:52 |
合計ジャッジ時間 | 11,528 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
// #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #include <bits/stdc++.h> using std::cin, std::cout, std::cerr; using ll = long long; struct Point { ll x, y; Point operator -(Point p) { return {x - p.x, y - p.y}; } ll Dot(Point p) { return x * p.x + y * p.y; } ll Length2() { return Dot(*this); } }; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; std::vector<Point> p(n); for(int i = 0; i < n; i ++) cin >> p[i].x >> p[i].y; std::vector<bool> del(n); auto simulate = [&]() { auto burst = del; std::vector<std::tuple<ll, int, int>> t; for(int i = 0; i < n; i ++) for(int j = i + 1; j < n; j ++) t.push_back({(p[i] - p[j]).Length2(), i, j}); std::ranges::sort(t); for(auto [l, i, j] : t) { if(burst[i] || burst[j]) continue; burst[i] = burst[j] = true; if(i == 0) return j; } return -1; }; int ans = 0; while(true) { int x = simulate(); if(x == -1) break; del[x] = true; ans ++; } cout << ans << '\n'; }