結果

問題 No.1265 Balloon Survival
ユーザー shiomusubi496
提出日時 2020-10-23 23:01:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 175,120 KB
実行使用メモリ 11,740 KB
最終ジャッジ日時 2024-07-21 12:10:25
合計ジャッジ時間 4,022 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
int dist(int A,int B){return A*A+B*B;}
int X[1100],Y[1100];
signed main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
    vector<pair<int,int>> A;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++)A.push_back({dist(X[i]-X[j],Y[i]-Y[j]),i*N+j});
    }
    sort(A.begin(),A.end());
    vector<int> B(N,-1);
    B[0]=0;
    for(auto p:A){
        int a=p.second/N,b=p.second%N;
        if(B[a]+B[b]==1)continue;
        if(!B[a])B[b]=0;
        else if(!B[b])B[a]=0;
        else B[a]=B[b]=1;
    }
    int ans=0;
    for(int i=1;i<N;i++){
        if(!B[i])ans++;
    }
    cout<<ans<<endl;
}
0