結果
| 問題 | No.1265 Balloon Survival |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-04 19:43:34 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 767 bytes |
| 記録 | |
| コンパイル時間 | 1,571 ms |
| コンパイル使用メモリ | 221,272 KB |
| 実行使用メモリ | 11,788 KB |
| 最終ジャッジ日時 | 2026-06-27 21:30:00 |
| 合計ジャッジ時間 | 3,624 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int N; cin >> N;
vector<ll> x(N), y(N);
rep(i,N) cin >> x[i] >> y[i];
vector<pair<ll,pair<int,int>>> e;
rep(i,N)rep(j,i) {
ll t = 0;
t += (x[i] - x[j]) * (x[i] - x[j]);
t += (y[i] - y[j]) * (y[i] - y[j]);
e.push_back({t, {i, j}});
}
sort(e.begin(), e.end());
vector<int> alive(N, 1);
int ans = 0;
for(auto [t, PAIR] : e) {
auto [i, j] = PAIR;
if(alive[i] && alive[j]) {
if(j == 0) ans++;
else alive[j] = 0;
alive[i] = 0;
}
}
cout << ans << endl;
}