結果

問題 No.1265 Balloon Survival
ユーザー iqueue02iqueue02
提出日時 2020-10-24 14:33:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 2,285 ms
コンパイル使用メモリ 211,880 KB
実行使用メモリ 20,984 KB
最終ジャッジ日時 2023-09-28 20:26:03
合計ジャッジ時間 5,434 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 16 ms
5,112 KB
testcase_15 AC 13 ms
5,120 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 70 ms
20,492 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 16 ms
5,328 KB
testcase_21 AC 33 ms
7,524 KB
testcase_22 AC 22 ms
8,264 KB
testcase_23 AC 24 ms
7,716 KB
testcase_24 AC 126 ms
19,888 KB
testcase_25 AC 126 ms
20,984 KB
testcase_26 AC 125 ms
19,820 KB
testcase_27 AC 127 ms
20,016 KB
testcase_28 AC 125 ms
19,584 KB
testcase_29 AC 126 ms
20,236 KB
testcase_30 AC 126 ms
20,428 KB
testcase_31 AC 125 ms
19,628 KB
testcase_32 AC 127 ms
20,080 KB
testcase_33 AC 126 ms
20,220 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef tuple<ll,int,int> TP;

int main() {
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  vector<TP> v;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      ll d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
      v.emplace_back(make_tuple(d, i, j));
    }
  }
  vector<int> used(n, 0);
  sort(v.begin(), v.end());
  int res = 0;
  for (auto e : v) {
    ll d;
    int a, b;
    tie(d, a, b) = e;
    if (used[a]) continue;
    if (used[b]) continue;
    if (a == 0 || b == 0) res++;
    if (a != 0) used[a] = 1;
    if (b != 0) used[b] = 1;
  }
  cout << res << endl;
  return 0;
}
0