結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー parukiparuki
提出日時 2017-05-01 12:02:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,679 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 177,592 KB
実行使用メモリ 7,464 KB
最終ジャッジ日時 2023-10-12 02:02:18
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 126 ms
7,464 KB
testcase_30 WA -
testcase_31 AC 101 ms
6,972 KB
testcase_32 AC 44 ms
7,340 KB
testcase_33 AC 83 ms
4,896 KB
testcase_34 AC 74 ms
4,632 KB
testcase_35 AC 121 ms
7,324 KB
testcase_36 AC 122 ms
7,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<class Value, class Cmp>
class RangeSumRMQ {
    int n;
    Value init;
    vector<Value> dat;
    vector<int> id;
    Cmp cmp;
    pair<Value, int> query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return make_pair(init, -1);
        if (a <= l&&r <= b) return make_pair(dat[k], id[k]);
        else {
            auto vl = query(a, b, k << 1, l, (l + r) >> 1);
            auto vr = query(a, b, (k << 1) | 1, (l + r) >> 1, r);
            return cmp(vl.first, vr.first) ? vl : vr;
        }
    }
    void update(int a, int b, int k, int l, int r, Value x) {
        if (a <= l && r <= b)dat[k] += x;
        else if (!(r <= a || b <= l)) {
            int lc = k << 1, rc = (k << 1) | 1;
            update(a, b, lc, l, (l + r) >> 1, x);
            update(a, b, rc, (l + r) >> 1, r, x);
            if (cmp(dat[lc], dat[rc]))id[k] = id[lc], dat[k] = dat[lc];
            else id[k] = id[rc], dat[k] = dat[rc];
        }
    }
public:
    RangeSumRMQ() {}
    RangeSumRMQ(int n_, Value init_) :n(1), init(init_) {
        for (; n < n_; n <<= 1);
        dat = vector<Value>(n << 1, init);
        id = vector<int>(n << 1);
        for (int i = 0; i < n; ++i)id[n + i] = i;
        for (int i = n - 1; i >= 1; --i)id[i] = id[i * 2];
    }
    void update(int a, int b, Value x) {
        update(a, b, 1, 0, n, x);
    }
    pair<Value, int> query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};
typedef RangeSumRMQ<long long, less<long long> > RSRMinQ;
typedef RangeSumRMQ<long long, greater<long long> > RSRMaxQ;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, w;
    ll h;
    cin >> n >> w >> h;
    vi a(n), b(n), x(n);

    RSRMaxQ rmq(w, 0);
    int A = 0, B = 0;
    const ll MI = (ll)-1e15;
    rep(i, n) {
        cin >> a[i] >> b[i] >> x[i];
        x[i]--;
        rmq.update(x[i], x[i] + a[i], b[i]);
        pair<ll, int> p;
        while (p = rmq.query(0, w), p.first >= h) {
            (i & 1 ? B : A)++;
            rmq.update(p.second, p.second + 1, MI);
        }
    }
    cout << (A > B ? "A" : A < B ? "B" : "DRAW") << endl;
}
0