結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2020-10-23 22:29:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 980 bytes |
コンパイル時間 | 2,486 ms |
コンパイル使用メモリ | 206,152 KB |
最終ジャッジ日時 | 2025-01-15 13:27:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include "bits/stdc++.h"//#include <atcoder/all>using namespace std;//using namespace atcoder;//#define int long long#define ll long longll INF = (1LL << 60);constexpr int mod = 1000000007;using P = pair<int, int>;void solve() {int N; cin >> N;vector<ll>x(N), y(N);for (int i = 0; i < N; i++) {cin >> x[i] >> y[i];}vector<pair<ll, P>>p;for (int i = 0; i < N; i++) {for (int j = i + 1; j < N; j++) {p.push_back({ (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]), {i, j} });}}sort(p.begin(), p.end());vector<bool>seen(N);ll ans = 0;for (int i = 0; i < p.size(); i++) {if (!seen[p[i].second.first] && !seen[p[i].second.second]) {if (p[i].second.first == 0) {ans++;seen[p[i].second.second] = true;}else {seen[p[i].second.first] = true;seen[p[i].second.second] = true;}}}cout << ans << endl;}signed main() {int t; t = 1;for (int i = 0; i < t; i++) {solve();}return 0;}