結果

問題 No.1265 Balloon Survival
ユーザー yamakeyamake
提出日時 2020-10-23 22:53:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,497 bytes
コンパイル時間 971 ms
コンパイル使用メモリ 95,952 KB
実行使用メモリ 16,868 KB
最終ジャッジ日時 2023-09-28 17:23:55
合計ジャッジ時間 4,023 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 14 ms
4,692 KB
testcase_15 AC 11 ms
4,740 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 68 ms
15,640 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 14 ms
4,692 KB
testcase_21 AC 31 ms
6,540 KB
testcase_22 AC 20 ms
6,300 KB
testcase_23 AC 21 ms
6,304 KB
testcase_24 AC 141 ms
15,836 KB
testcase_25 AC 143 ms
16,144 KB
testcase_26 AC 142 ms
16,868 KB
testcase_27 AC 140 ms
16,668 KB
testcase_28 AC 142 ms
15,668 KB
testcase_29 AC 144 ms
16,056 KB
testcase_30 AC 147 ms
16,132 KB
testcase_31 AC 144 ms
15,500 KB
testcase_32 AC 145 ms
15,680 KB
testcase_33 AC 143 ms
15,452 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint=long long;
using P= pair<lint,lint>;
int MOD=1000000007;
lint d2(P& a,P& b){
    return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}

signed main(){
    int n;cin>>n;
    vector<pair<lint,lint>> b(n);
    rep(i,n)cin>>b[i].first>>b[i].second;
    priority_queue<pair<lint,P>,vector<pair<lint,P>>,greater<>> que;
    rep(i,n){
        for(int j=i+1;j<n;++j){
            que.push({d2(b[i],b[j]),{i,j}});
        }
    }
    vector<int> memo(n,0);
    int res=0;
    map<int,int> hoge;
    lint dist=0;
    while(!que.empty()){
        auto buf=que.top();que.pop();
        if(dist!=buf.first){
            dist=buf.first;
            for(auto& val:hoge){
                memo[val.first]=1;
            }
            hoge.clear();
        }
        if(memo[buf.second.first]>0||memo[buf.second.second]>0){
                continue;
            }
        if(buf.second.first==0||buf.second.second==0){
            ++res;
            memo[buf.second.first+buf.second.second]=1;
        }
        else{
            hoge[buf.second.first]=1;
            hoge[buf.second.second]=1;
        }
    }

    cout<<res<<"\n";
    return 0;
}
0