結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー minamiminami
提出日時 2017-04-28 23:38:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,152 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 166,092 KB
実行使用メモリ 8,700 KB
最終ジャッジ日時 2023-10-11 19:49:56
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,700 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 1 ms
4,356 KB
testcase_19 AC 2 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 3 ms
4,348 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 3 ms
4,352 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 4 ms
4,352 KB
testcase_28 AC 4 ms
4,352 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int SQRT_N = 317;
const int MAX_N = SQRT_N*SQRT_N;
int dat[MAX_N] = {};
int bucket_max[SQRT_N] = {};
int bucket_add[SQRT_N] = {};
int lazy_bucket_update[SQRT_N] = {};
bool lazy_flag_update[SQRT_N] = {};

int n, w, h;

void add(int l, int r, int val) {
	for (int k = 0; k < SQRT_N; k++) {
		int bl = k * SQRT_N, br = (k + 1) * SQRT_N;
		if (r <= bl || br <= l)
			continue;
		if (l <= bl && br <= r) {
			bucket_add[k] += val;
			bucket_max[k] += val;
		}
		else {
			int maxi = 0;
			for (int i = bl; i < br; i++) {
				if (l <= i&&i < r)
					dat[i] += val;
				if (dat[i] + bucket_add[k] < h)
					chmax(maxi, dat[i] + bucket_add[k]);
			}
			chmax(bucket_max[k], maxi);
		}
	}
}

int query(int a, int b, int x) {
	int l = x - 1, r = x - 1 + a;
	int ret = 0;
	for (int k = 0; k < SQRT_N; k++) {
		int bl = k * SQRT_N, br = (k + 1) * SQRT_N;
		if (r <= bl || br <= l)
			continue;
		if (l <= bl && br <= r) {
			if (bucket_max[k] + b >= h) {
				rep(i, bl, br) {
					if (dat[i] + bucket_add[k] < h && dat[i] + bucket_add[k] + b >= h)
						ret++;
				}
			}
		}
		else {
			for (int i = max(l, bl); i < min(r, br); i++) {
				if (dat[i] + bucket_add[k] < h &&dat[i] + bucket_add[k] + b >= h)
					ret++;
			}
		}
	}
	add(l, r, b);
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> w >> h;
	int p[2] = {};
	rep(i, 0, n) {
		int a, b, x; cin >> a >> b >> x;
		p[i & 1] += query(a, b, x);
	}
	dump(p);
	if (p[0] > p[1])
		cout << "A" << endl;
	else if (p[0] < p[1])
		cout << "B" << endl;
	else
		cout << "DRAW" << endl;
	return 0;
}
0