結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2020-10-23 22:54:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 229 ms / 2,000 ms |
コード長 | 854 bytes |
コンパイル時間 | 1,924 ms |
コンパイル使用メモリ | 179,476 KB |
実行使用メモリ | 30,692 KB |
最終ジャッジ日時 | 2024-07-21 12:04:29 |
合計ジャッジ時間 | 6,007 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < (ll)(n); i++)using namespace std;typedef long long ll;int main() {ll N;cin >> N;vector<ll> x(N), y(N);rep(i, N) cin >> x[i] >> y[i];vector<vector<ll>> d;for (ll i = 0; i < N - 1; i++) {for (ll j = i + 1; j < N; j++) {d.push_back({(x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]), i, j});}}sort(d.begin(), d.end());vector<bool> done(N, false);ll ans = 0;rep(i, d.size()) {if (done[d[i][1]] || done[d[i][2]]) continue;//cout << d[i][1] << " " << d[i][2] << "\n";if (d[i][1] == 0) {done[d[i][2]] = true;ans++;} else {done[d[i][1]] = true;done[d[i][2]] = true;}}cout << ans << "\n";}