結果

問題 No.1265 Balloon Survival
ユーザー 👑 CleyLCleyL
提出日時 2022-10-22 03:32:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 89,228 KB
最終ジャッジ日時 2025-02-08 10:55:08
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

struct d{
  int x,y;
  long long l;
  const bool operator<(d b){
    if(l == b.l){
      if(x == b.x){
        return y < b.y;
      }
      return x < b.x;
    }
    return l < b.l;
  }
};

int main(){
  int n;cin>>n;
  vector<pair<long long,long long>> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i].first>>A[i].second;
  }
  vector<d> B;
  for(int i = 0; n > i; i++){
    for(int j = i+1; n > j; j++){
      B.push_back({i,j,(A[i].first-A[j].first)*(A[i].first-A[j].first)+(A[i].second-A[j].second)*(A[i].second-A[j].second)});
    }
  }
  sort(B.begin(),B.end());
  set<int> X;
  int ans = 0;
  for(int i = 0; B.size() > i; i++){
    if(B[i].x == 0){
      if(!X.count(B[i].y)){
        ans++;
        X.insert(B[i].y);
      }
    }else{
      if(!X.count(B[i].x) && !X.count(B[i].y)){
        X.insert(B[i].x);
        X.insert(B[i].y);
      }
    }
  }
  cout << ans << endl;
}
0