結果

問題 No.1265 Balloon Survival
ユーザー marroncastle
提出日時 2020-10-23 22:47:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,293 bytes
コンパイル時間 4,655 ms
コンパイル使用メモリ 269,668 KB
最終ジャッジ日時 2025-01-15 13:42:28
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

// g++ A.cpp -std=c++14 -I . && ./a.out
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll INF = 1e18;
// 変数定義
int N, M, Q, a, b, c, d, e, x, y, T, total, cnt, ans;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;
  vector<ll> X(N), Y(N);
  rep(i, N)
  {
    cin >> X[i] >> Y[i];
  }
  vector<vector<ll>> dists;
  rep(i, N)
  {
    rep2(j, i + 1, N)
    {
      dists.push_back({(X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]), i, j});
    }
  }
  sort(all(dists));
  vector<bool> check(N, false);
  for (auto dist : dists)
  {
    // cout << dist[0] << ' ' << dist[1] << ' ' << dist[2] << '\n';
    // cout << ans << '\n';
    if (dist[1] == 0)
    {
      if (check[dist[2]] == false)
      {
        ans++;
        check[dist[2]] = true;
      }
    }
    else if (check[dist[1]] == false && check[dist[2]] == false)
    {
      check[dist[1]] = true;
      check[dist[2]] = true;
    }
  }
  cout << ans << '\n';
  return 0;
}
0