結果

問題 No.1265 Balloon Survival
ユーザー shiomusubi496shiomusubi496
提出日時 2020-10-23 23:01:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 174,008 KB
実行使用メモリ 13,392 KB
最終ジャッジ日時 2023-09-28 17:31:48
合計ジャッジ時間 4,099 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,384 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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