結果

問題 No.973 余興
ユーザー 👑 jupirojupiro
提出日時 2020-01-18 17:52:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,226 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 117,580 KB
実行使用メモリ 394,784 KB
最終ジャッジ日時 2023-09-10 06:59:30
合計ジャッジ時間 76,150 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,127 ms
394,756 KB
testcase_01 AC 2,082 ms
394,588 KB
testcase_02 AC 2,116 ms
394,356 KB
testcase_03 AC 2,115 ms
394,260 KB
testcase_04 AC 2,152 ms
394,776 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2,030 ms
378,972 KB
testcase_11 AC 683 ms
143,996 KB
testcase_12 AC 683 ms
144,248 KB
testcase_13 WA -
testcase_14 AC 674 ms
142,888 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 19 ms
12,808 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 38 ms
18,876 KB
testcase_23 AC 29 ms
15,676 KB
testcase_24 AC 29 ms
15,708 KB
testcase_25 AC 11 ms
8,876 KB
testcase_26 AC 19 ms
12,460 KB
testcase_27 AC 46 ms
21,604 KB
testcase_28 WA -
testcase_29 AC 27 ms
15,496 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2,203 ms
392,828 KB
testcase_35 AC 2,134 ms
394,640 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2,137 ms
393,268 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 2,174 ms
394,592 KB
testcase_47 WA -
testcase_48 AC 2,174 ms
394,556 KB
testcase_49 WA -
testcase_50 AC 2,204 ms
391,484 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 2,094 ms
387,784 KB
testcase_54 AC 2,130 ms
394,468 KB
testcase_55 AC 2,177 ms
394,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

class BIT {
private:
	ll N;
	vector<ll> node;
public:
	BIT(ll M) {
		node = vector<ll>(M + 1, 0);
		N = M;
	}

	ll sum(ll i) {
		ll s = 0;
		while (i > 0) {
			s += node[i];
			i -= i & -i;
		}
		return s;
	}

	ll sum(ll i, ll j) {
		ll l = sum(i - 1);
		ll r = sum(j);
		return r - l;
	}

	void add(ll i, ll x) {
		while (i <= N) {
			node[i] += x;
			i += i & -i;
		}
	}
};


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll N, X; scanf("%lld %lld", &N, &X);
	vector<ll> a(N); for (ll i = 0; i < N; i++) scanf("%lld", &a[i]);
	vector<ll> rb(N);
	vector<ll> lb(N);
	for (ll i = 0; i < N; i++) {
		ll j = i;
		ll sum = 0;
		while (j < N && sum + a[j] <= X) {
			rb[i] = j;
			sum += a[j];
			j++;
		}
	}
	for (ll i = N - 1; i >= 0; i--) {
		ll j = i;
		ll sum = 0;
		while (j >= 0 && sum + a[j] <= X) {
			lb[i] = j;
			sum += a[j];
			j--;
		}
	}

	vector<BIT> vbl(N, BIT(N + 1)), vbr(N, BIT(N + 1));
	for (ll len = 1; len <= N; len++) {
		for (ll left = 0; left + len - 1 < N; left++) {
			ll right = left + len - 1;
			ll lose = 1;
			//cout << right << endl;
			if (vbl[left].sum(left + 1, max(lb[right], right) + 1)) lose = 0;
			if (vbr[right].sum(min(left, rb[left]) + 1, right + 1)) lose = 0;
			if (lose) {
				vbl[left].add(right + 1, 1);
				vbr[right].add(left + 1, 1);
			}
		}
	}
	if (vbl[0].sum(N,N)) puts("B");
	else puts("A");
	return 0;
}
0