結果

問題 No.1265 Balloon Survival
ユーザー abc3abc3
提出日時 2020-10-24 00:07:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 3,770 ms
コンパイル使用メモリ 207,788 KB
実行使用メモリ 12,644 KB
最終ジャッジ日時 2023-09-28 19:26:02
合計ジャッジ時間 5,181 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 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,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 13 ms
4,376 KB
testcase_15 AC 10 ms
4,404 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 60 ms
12,528 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 28 ms
5,016 KB
testcase_22 AC 18 ms
5,072 KB
testcase_23 AC 19 ms
5,072 KB
testcase_24 AC 120 ms
12,040 KB
testcase_25 AC 122 ms
11,568 KB
testcase_26 AC 120 ms
12,104 KB
testcase_27 AC 120 ms
12,176 KB
testcase_28 AC 118 ms
11,476 KB
testcase_29 AC 121 ms
11,812 KB
testcase_30 AC 118 ms
12,204 KB
testcase_31 AC 117 ms
12,644 KB
testcase_32 AC 118 ms
12,136 KB
testcase_33 AC 118 ms
12,172 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF=1001001001;
const int mod=1000000007;

int main() {
  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<int64_t,pair<int,int>>>q;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int64_t dx=x[j]-x[i],dy=y[j]-y[i];
      int64_t dis=dx*dx+dy*dy;
      q.push(make_pair(-dis,make_pair(i,j)));
    }
  }
  vector<bool>seen(N,false);
  int cnt=0;
  while(!q.empty()){
    int d=q.top().first,i=q.top().second.first,j=q.top().second.second;
    q.pop();
    if(i==0||j==0){
      if(!seen[i+j-0]){cnt++;seen[i+j-0]=true;}//i+j-0=0の相方
    }
    else if(!seen[i]&&!seen[j]){seen[i]=true;seen[j]=true;}
  }
  cout<<cnt<<endl;
  return 0;
}
0