結果

問題 No.1265 Balloon Survival
ユーザー kyo1
提出日時 2020-11-18 08:26:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 2,790 ms
コンパイル使用メモリ 205,140 KB
最終ジャッジ日時 2025-01-16 01:29:24
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  priority_queue<pair<double, pair<int, int>>, vector<pair<double, pair<int, int>>>,
                 greater<pair<double, pair<int, int>>>>
      que;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      que.push(make_pair(sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j])),
                         make_pair(i, j)));
    }
  }
  int res = 0;
  set<int> st;
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int a = q.second.first, b = q.second.second;
    if (a == 0 && st.find(b) == st.end()) {
      res++;
      st.insert(b);
    }
    if (st.find(a) == st.end() && st.find(b) == st.end()) {
      st.insert(a);
      st.insert(b);
    }
  }
  cout << res << '\n';
  return 0;
}
0