結果

問題 No.973 余興
ユーザー 👑 jupirojupiro
提出日時 2020-01-18 16:25:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,389 bytes
コンパイル時間 1,091 ms
コンパイル使用メモリ 117,504 KB
実行使用メモリ 394,824 KB
最終ジャッジ日時 2023-09-09 23:48:01
合計ジャッジ時間 14,378 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 292 ms
394,484 KB
testcase_01 AC 288 ms
394,464 KB
testcase_02 AC 286 ms
394,288 KB
testcase_03 AC 289 ms
394,020 KB
testcase_04 AC 287 ms
394,672 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 277 ms
378,952 KB
testcase_11 AC 114 ms
144,012 KB
testcase_12 AC 114 ms
144,088 KB
testcase_13 WA -
testcase_14 AC 114 ms
142,964 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 8 ms
12,844 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 11 ms
18,940 KB
testcase_23 AC 9 ms
15,744 KB
testcase_24 AC 9 ms
15,740 KB
testcase_25 AC 5 ms
9,080 KB
testcase_26 AC 7 ms
12,576 KB
testcase_27 AC 14 ms
21,600 KB
testcase_28 WA -
testcase_29 AC 10 ms
15,440 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 304 ms
392,744 KB
testcase_35 AC 305 ms
394,556 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 303 ms
393,136 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 310 ms
394,516 KB
testcase_47 WA -
testcase_48 AC 311 ms
394,648 KB
testcase_49 WA -
testcase_50 AC 309 ms
391,440 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 293 ms
387,788 KB
testcase_54 AC 293 ms
394,788 KB
testcase_55 AC 299 ms
394,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: メンバ関数 ‘ll BIT::sum0(ll, ll)’ 内:
main.cpp:76:9: 警告: 非 void を戻す関数内に return 文がありません [-Wreturn-type]
   76 |         }
      |         ^

ソースコード

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;
		}
	}
	//0-indexed
	void add0(ll i, ll x) {
		add(i + 1, x);
	}
	//0-indexed [i, j)
	ll sum0(ll i, ll j) {
		sum(i + 1, j);
	}
};


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 i = 0; i < N; i++) {
		vbl[i].add0(i, 1);
		vbr[i].add0(i, 1);
	}
	for (ll len = 1; len <= N; len++) {
		for (ll left = 0; left + len - 1 < N; left++) {
			ll right = left + len;
			ll lose = 1;
			if(vbl[left].sum0(left, min(right, rb[left] + 1))) lose = 0;
			if (vbr[right - 1].sum0(max(left, lb[right - 1]), right)) lose = 0;
			if (lose) {
				vbl[left].add0(left, 1);
				vbr[right - 1].add0(right - 1, 1);
			}
		}
	}
	if (vbl[0].sum(N,N)) puts("B");
	else puts("A");
	return 0;
}
0