結果

問題 No.1265 Balloon Survival
ユーザー zuminzumin
提出日時 2021-03-28 16:23:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 90,412 KB
実行使用メモリ 11,072 KB
最終ジャッジ日時 2023-08-19 15:37:42
合計ジャッジ時間 3,860 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
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 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;

int main(){
    int n,ans=0;
    cin>>n;
    vector<int> x(n),y(n),kil(n,0);
    priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>> q;

    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int xi,yi,xj,yj;
            xi=x[i],yi=y[i],xj=x[j],yj=y[j];
            q.push(make_tuple(pow(xi-xj,2)+pow(yi-yj,2),i,j));
        }
    }
    while(q.size()){
        int d,i,j;
        tie(d,i,j)=q.top();q.pop();
        if(kil[i]||kil[j]) continue;
        if(i!=0&&j!=0){
            kil[i]=1;
            kil[j]=1;
        }else{
            kil[j]=1;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0