結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー e869120e869120
提出日時 2018-06-10 11:49:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,431 ms / 4,000 ms
コード長 1,630 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 77,952 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-08-16 03:10:26
合計ジャッジ時間 12,248 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 8 ms
4,380 KB
testcase_26 AC 8 ms
4,376 KB
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 12 ms
4,376 KB
testcase_29 AC 1,431 ms
7,960 KB
testcase_30 AC 1,164 ms
7,404 KB
testcase_31 AC 1,062 ms
6,996 KB
testcase_32 AC 1,117 ms
7,068 KB
testcase_33 AC 1,102 ms
6,424 KB
testcase_34 AC 968 ms
5,956 KB
testcase_35 AC 1,407 ms
7,876 KB
testcase_36 AC 1,408 ms
7,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long H, W, N, X[100009], A[100009], B[100009], bit[100009];
long long Backet = 300, D[1009]; vector<long long>F[1009];

long long refresh(long long l, long long r, long long x, long long E) {
	long long sum = 0, A = D[E];
	for (int i = E*Backet; i < (E + 1)*Backet; i++) {
		if (l <= i && i <= r) {
			if (bit[i] + A >= H - x && bit[i] + A < H) sum++; bit[i] += x;
		}
	}
	F[E].clear();
	for (int i = E*Backet; i < (E + 1)*Backet; i++) F[E].push_back(bit[i]);
	sort(F[E].begin(), F[E].end());
	return sum;
}
long long gets(long long p, long long x) {
	int pos1 = lower_bound(F[p].begin(), F[p].end(), H - D[p]) - F[p].begin();
	long long sum = 0;
	for (int i = pos1 - 1; i >= 0; i--) {
		if (F[p][i] >= (H - x) - D[p]) sum++;
		else break;
	}
	D[p] += x;
	return sum;
}

long long add(long long l, long long r, long long x) {
	if (l / Backet == r / Backet) {
		return refresh(l, r, x, l / Backet);
	}
	long long L = l / Backet, R = r / Backet, ret = 0;
	ret += refresh(l, r, x, L);
	ret += refresh(l, r, x, R);
	for (int i = L + 1; i <= R - 1; i++) ret += gets(i, x);
	return ret;
}

int main() {
	cin >> N >> W >> H;
	long long A1 = 0, B1 = 0;
	for (int i = 1; i <= W; i++) F[i / Backet].push_back(0);
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i] >> X[i];
		long long G = add(X[i], X[i] + A[i] - 1, B[i]);
		if (i % 2 == 1) A1 += G;
		else B1 += G;
		//cout << "! " << i << " " << A1 << " " << B1 << endl << endl;
	}
	if (A1 > B1) cout << "A" << endl;
	else if (A1 < B1) cout << "B" << endl;
	else cout << "DRAW" << endl;
	return 0;
}
0