結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー latte0119latte0119
提出日時 2017-04-28 22:50:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 166 ms / 4,000 ms
コード長 2,011 bytes
コンパイル時間 1,320 ms
コンパイル使用メモリ 154,576 KB
実行使用メモリ 9,556 KB
最終ジャッジ日時 2023-08-16 03:07:36
合計ジャッジ時間 4,216 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
9,424 KB
testcase_01 AC 6 ms
9,360 KB
testcase_02 AC 6 ms
8,972 KB
testcase_03 AC 6 ms
9,508 KB
testcase_04 AC 6 ms
9,416 KB
testcase_05 AC 6 ms
9,368 KB
testcase_06 AC 6 ms
9,312 KB
testcase_07 AC 5 ms
9,368 KB
testcase_08 AC 6 ms
9,424 KB
testcase_09 AC 5 ms
9,312 KB
testcase_10 AC 6 ms
9,312 KB
testcase_11 AC 5 ms
9,368 KB
testcase_12 AC 6 ms
8,972 KB
testcase_13 AC 6 ms
8,988 KB
testcase_14 AC 5 ms
9,368 KB
testcase_15 AC 5 ms
8,988 KB
testcase_16 AC 6 ms
9,368 KB
testcase_17 AC 6 ms
9,380 KB
testcase_18 AC 5 ms
9,368 KB
testcase_19 AC 5 ms
9,312 KB
testcase_20 AC 6 ms
9,376 KB
testcase_21 AC 7 ms
9,368 KB
testcase_22 AC 7 ms
9,320 KB
testcase_23 AC 6 ms
9,360 KB
testcase_24 AC 6 ms
9,364 KB
testcase_25 AC 7 ms
9,376 KB
testcase_26 AC 7 ms
8,988 KB
testcase_27 AC 7 ms
9,436 KB
testcase_28 AC 7 ms
9,472 KB
testcase_29 AC 165 ms
9,384 KB
testcase_30 AC 155 ms
9,556 KB
testcase_31 AC 139 ms
9,440 KB
testcase_32 AC 106 ms
9,372 KB
testcase_33 AC 121 ms
8,968 KB
testcase_34 AC 111 ms
9,368 KB
testcase_35 AC 166 ms
9,436 KB
testcase_36 AC 164 ms
9,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

struct segtree{
    static const int SEG=1<<17;
    vpint dat;
    vint put;
    segtree(int n):dat(SEG*2,pint(-INF,0)),put(SEG*2,0){
        for(int i=0;i<n;i++){
            dat[i+SEG-1].fi=0;
            dat[i+SEG-1].se=i;
        }
        for(int i=SEG-2;i>=0;i--)dat[i]=max(dat[i*2+1],dat[i*2+2]);
    }

    inline void push(int k){
        dat[k].fi+=put[k];
        if(k<SEG-1){
            put[k*2+1]+=put[k];
            put[k*2+2]+=put[k];
        }
        put[k]=0;
    }
    void add(int a,int b,int x,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]+=x;
            push(k);
            return;
        }
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
    pint query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return pint(-INF,0);
        if(a<=l&&r<=b)return dat[k];
        return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
};

signed main(){
    int N,W,H;
    scanf("%lld%lld%lld",&N,&W,&H);
    segtree seg(W);

    int P[2]={};
    rep(i,N){
        int a,b,x;
        scanf("%lld%lld%lld",&a,&b,&x);
        x--;
        seg.add(x,x+a,b);
        while(true){
            auto p=seg.query(0,W);
            if(p.fi<H)break;
            seg.add(p.se,p.se+1,-INF);
            P[i&1]++;
        }
    }

    if(P[0]>P[1])cout<<"A"<<endl;
    else if(P[0]<P[1])cout<<"B"<<endl;
    else cout<<"DRAW"<<endl;
    return 0;

}
0