結果
問題 | No.973 余興 |
ユーザー | drken1215 |
提出日時 | 2020-01-18 19:25:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,509 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 81,416 KB |
実行使用メモリ | 395,520 KB |
最終ジャッジ日時 | 2024-06-28 01:30:05 |
合計ジャッジ時間 | 91,796 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,195 ms
395,392 KB |
testcase_01 | AC | 2,212 ms
395,392 KB |
testcase_02 | AC | 2,183 ms
395,136 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 2,128 ms
395,264 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2,192 ms
393,728 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 52 ms
19,456 KB |
testcase_17 | AC | 31 ms
13,184 KB |
testcase_18 | WA | - |
testcase_19 | AC | 40 ms
16,256 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 52 ms
19,328 KB |
testcase_23 | WA | - |
testcase_24 | AC | 40 ms
15,872 KB |
testcase_25 | AC | 18 ms
8,960 KB |
testcase_26 | AC | 30 ms
12,928 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 42 ms
15,744 KB |
testcase_30 | WA | - |
testcase_31 | AC | 2,998 ms
395,264 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 2,900 ms
393,472 KB |
testcase_35 | WA | - |
testcase_36 | AC | 2,886 ms
384,768 KB |
testcase_37 | AC | 2,855 ms
384,896 KB |
testcase_38 | WA | - |
testcase_39 | AC | 2,929 ms
394,496 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 2,865 ms
395,136 KB |
testcase_48 | WA | - |
testcase_49 | AC | 2,567 ms
364,672 KB |
testcase_50 | WA | - |
testcase_51 | AC | 2,917 ms
395,392 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; 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; } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template <class Abel> struct BIT { const Abel UNITY_SUM = 0; // to be set vector<Abel> dat; /* [1, n] */ BIT(int n) : dat(n + 1, UNITY_SUM) { } void init(int n) { dat.assign(n + 1, UNITY_SUM); } /* a is 1-indexed */ inline void add(int a, Abel x) { for (int i = a; i < (int)dat.size(); i += i & -i) dat[i] = dat[i] + x; } /* [1, a], a is 1-indexed */ inline Abel sum(int a) { Abel res = UNITY_SUM; for (int i = a; i > 0; i -= i & -i) res = res + dat[i]; return res; } /* [a, b), a and b are 1-indexed */ inline Abel sum(int a, int b) { return sum(b - 1) - sum(a - 1); } /* debug */ void print() { for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ","; cout << endl; } }; int N; long long X; vector<long long> a, s; vector<int> l2r, r2l; bool solve() { l2r.assign(N+1, -1), r2l.assign(N+1, -1); int r = 0; for (int l = 0; l < N; ++l) { while (r < N && s[r + 1] - s[l] <= X) { ++r; r2l[r] = l; } l2r[l] = r; } //COUT(l2r); COUT(r2l); vector<BIT<long long> > sente(N+5, BIT<long long>(N+5)); vector<BIT<long long> > gote(N+5, BIT<long long>(N+5)); for (int l = 0; l <= N; ++l) sente[l].add(l+1, 1); for (int r = 0; r <= N; ++r) gote[r].add(r+1, 1); for (int bet = 1; bet <= N; ++bet) { for (int l = 0; l+bet <= N; ++l) { int r = l + bet; // l+1, ..., min(l2r[l], r) に「負け」があれば OK long long mi = min(l2r[l], r); long long tmp = (mi-l) - gote[r].sum(l+2, mi+2); //cout << l << ", " << r << ": " << make_pair(l+1, min(l2r[l], r)) << endl; if (tmp) sente[l].add(r+1, 1); // max(l+1, r2l[r]), ..., r-1 に「負け」があれば OK long long ma = max(l, r2l[r]); tmp = (r-ma) - sente[l].sum(ma+1, r+1); if (tmp) gote[r].add(l+1, 1); //cout << l << ", " << r << ": " << (sente[l].sum(r+1, r+2) ? "lose" : "win") << ", " << (gote[r].sum(l+1, l+2) ? "lose" : "win") << endl; } } /* for (int l = 0; l <= N; ++l) { COUT(l); cout << "sente: "; sente[l].print(); cout << "gote: "; gote[l].print(); } */ return sente[0].sum(N+1, N+2); } int main() { while (cin >> N >> X) { a.resize(N); s.assign(N+1, 0); for (int i = 0; i < N; ++i) cin >> a[i], s[i+1] = s[i] + a[i]; if (solve()) cout << "A" << endl; else cout << "B" << endl; } }