結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
const int W = 1e5 + 5;

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

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

int query (int l, int r, int s, int t, int x)
{
	if (s == t)
	{
		tree[x] = -1e9;
		return 1;
	}
	int ans = 0, mid = (s + t) / 2;
	if (l <= mid && tree[x * 2] >= h)	ans += query (l, r, s, mid, x * 2);
	if (r > mid && tree[x * 2 + 1] >= h)	ans += query (l, r, mid + 1, t, x * 2 + 1);
	return ans;
}

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