結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー Yao Cai
提出日時 2025-03-29 12:48:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 93 ms / 4,000 ms
コード長 1,548 bytes
コンパイル時間 2,319 ms
コンパイル使用メモリ 192,844 KB
実行使用メモリ 8,400 KB
最終ジャッジ日時 2025-03-29 12:48:54
合計ジャッジ時間 4,365 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:53:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |     scanf("%lld%lld%lld", &n, &w, &h);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:56:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 |         scanf("%lld%lld%lld", &a, &b, &x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

const int W = 1e5 + 5;

int n, w, h, score[2], b[4 * W], tree[4 * W];

void push_down(int x) 
{
    if (b[x]) 
	{
        tree[x * 2] += b[x], tree[x * 2 + 1] += b[x];
        b[x * 2] += b[x], b[x * 2 + 1] += b[x];
        b[x] = 0;
    }
}

void get(int l, int r, int x, int id) 
{
    if (tree[x] < h) return;
    if (l == r) 
	{
        tree[x] = -1e18;
        score[id]++;
        return;
    }
    push_down(x);
    int mid = (l + r) / 2;
    if (tree[x * 2] >= h) get(l, mid, x * 2, id);
    if (tree[x * 2 + 1] >= h) get(mid + 1, r, x * 2 + 1, id);
    tree[x] = max(tree[2 * x], tree[2 * x + 1]);
}

void update(int l, int r, int s, int t, int k, int x, int id) 
{
    if (l <= s && t <= r) 
	{
        tree[x] += k, b[x] += k;
        if (tree[x] >= h) get(s, t, x, id);
        return;
    }
    push_down(x);
    int mid = (s + t) / 2;
    if (l <= mid) update(l, r, s, mid, k, x * 2, id);
    if (r > mid) update(l, r, mid + 1, t, k, x * 2 + 1, id);
    tree[x] = max(tree[2 * x], tree[2 * x + 1]);
}

signed main() {
    //freopen ("game.in", "r", stdin);
    //freopen ("game.out", "w", stdout);
    scanf("%lld%lld%lld", &n, &w, &h);
    for (int i = 1; i <= n; i++) {
        int a, b, x;
        scanf("%lld%lld%lld", &a, &b, &x);
        if (score[0] + score[1] == w) break;
        update(x, a + x - 1, 1, w, b, 1, i % 2);
    }
    if (score[1] > score[0]) printf("A");
    else if (score[1] < score[0]) printf("B");
    else printf("DRAW");
    return 0;
}
0