結果
問題 | No.973 余興 |
ユーザー | shibh308 |
提出日時 | 2019-12-06 08:03:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,166 ms / 4,000 ms |
コード長 | 2,363 bytes |
コンパイル時間 | 2,502 ms |
コンパイル使用メモリ | 208,908 KB |
実行使用メモリ | 199,168 KB |
最終ジャッジ日時 | 2024-05-10 01:56:18 |
合計ジャッジ時間 | 66,897 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,780 ms
199,040 KB |
testcase_01 | AC | 1,762 ms
199,040 KB |
testcase_02 | AC | 1,772 ms
199,040 KB |
testcase_03 | AC | 1,762 ms
198,912 KB |
testcase_04 | AC | 1,802 ms
199,040 KB |
testcase_05 | AC | 1,829 ms
199,040 KB |
testcase_06 | AC | 1,774 ms
199,040 KB |
testcase_07 | AC | 1,782 ms
199,040 KB |
testcase_08 | AC | 1,778 ms
198,272 KB |
testcase_09 | AC | 1,799 ms
199,040 KB |
testcase_10 | AC | 1,699 ms
191,232 KB |
testcase_11 | AC | 616 ms
73,856 KB |
testcase_12 | AC | 606 ms
73,984 KB |
testcase_13 | AC | 613 ms
73,216 KB |
testcase_14 | AC | 608 ms
73,216 KB |
testcase_15 | AC | 43 ms
11,392 KB |
testcase_16 | AC | 43 ms
11,520 KB |
testcase_17 | AC | 26 ms
8,448 KB |
testcase_18 | AC | 34 ms
9,856 KB |
testcase_19 | AC | 35 ms
9,728 KB |
testcase_20 | AC | 25 ms
8,192 KB |
testcase_21 | AC | 43 ms
11,264 KB |
testcase_22 | AC | 42 ms
11,392 KB |
testcase_23 | AC | 34 ms
9,856 KB |
testcase_24 | AC | 32 ms
9,728 KB |
testcase_25 | AC | 14 ms
6,400 KB |
testcase_26 | AC | 25 ms
8,320 KB |
testcase_27 | AC | 54 ms
12,416 KB |
testcase_28 | AC | 33 ms
9,856 KB |
testcase_29 | AC | 33 ms
9,856 KB |
testcase_30 | AC | 2,166 ms
199,040 KB |
testcase_31 | AC | 1,955 ms
199,040 KB |
testcase_32 | AC | 1,960 ms
199,168 KB |
testcase_33 | AC | 1,952 ms
198,912 KB |
testcase_34 | AC | 1,909 ms
198,144 KB |
testcase_35 | AC | 1,907 ms
199,040 KB |
testcase_36 | AC | 1,872 ms
193,792 KB |
testcase_37 | AC | 1,883 ms
193,792 KB |
testcase_38 | AC | 1,967 ms
198,400 KB |
testcase_39 | AC | 1,964 ms
198,656 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 1 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 1 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 1,907 ms
199,040 KB |
testcase_47 | AC | 1,870 ms
199,040 KB |
testcase_48 | AC | 1,869 ms
199,040 KB |
testcase_49 | AC | 1,717 ms
183,680 KB |
testcase_50 | AC | 1,862 ms
197,504 KB |
testcase_51 | AC | 1,889 ms
199,168 KB |
testcase_52 | AC | 1,940 ms
199,040 KB |
testcase_53 | AC | 1,847 ms
195,584 KB |
testcase_54 | AC | 1,927 ms
198,912 KB |
testcase_55 | AC | 1,958 ms
199,040 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; using i64 = long long; template <typename T> struct BIT{ vector<T> elm; BIT(int n, T init = T()) : elm(n + 1, init){ } // [0, x) T sum(int x){ T val = 0; for(; x > 0; x -= x & -x) val += elm[x]; return val; } // [l, r) T sum(int l, int r){ return sum(r) - sum(l); } void add(int x, T val){ for(++x; x < elm.size(); x += x & -x) elm[x] += val; } }; signed main(){ int n, x; cin >> n >> x; vector<int> v(n); for(auto& w : v) cin >> w; vector<i64> r(n + 1, 0); for(int i = 0; i < n; ++i) r[i + 1] = r[i] + v[i]; vector<int> nex(n, n), prev(n, 0); for(int i = 0; i < n; ++i){ auto it = upper_bound(r.begin(), r.end(), r[i] + x); int idx = distance(r.begin(), it); nex[i] = min(idx, n); auto it2 = lower_bound(r.begin(), r.end(), r[i + 1] - x); idx = distance(r.begin(), it2); prev[i] = max(0, idx - 1); } /* for(auto& x : nex) cout << x << " "; cout << endl; for(auto& x : prev) cout << x << " "; cout << endl; */ vector<BIT<int>> a(n, BIT<int>(n)), b(n, BIT<int>(n)); for(int k = 1; k < n; ++k) for(int i = 0, j = k; j < n; ++i, ++j){ bool f = false; // TODO: set len // dp[i][j] : dp[i][j - x, j) // cout << j - prev[j] << " " << nex[i] - (i + 1) << " "; f |= (a[i].sum(max(i, prev[j]), j) != (j - max(i, prev[j]))); // dp[i][j] : dp[i, i + x][j, j) f |= (b[j].sum(i + 1, min(nex[i], j + 1)) != (min(nex[i], j + 1) - (i + 1))); if(f){ a[i].add(j, 1); b[j].add(i, 1); } /* cout << "[" << i << ",[" << max(i, prev[j]) << "," << j - 1 << "]] : "; cout << "[[" << i + 1 << "," << min(nex[j], j + 1) - 1 << "]," << j << "] : "; cout << "[" << i << "," << j << "] -> " << (f ? "Win" : "Lose") << endl; */ } /* for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j) cout << a[i].sum(j, j + 1) << " \n"[j == n - 1]; } cout << endl; */ cout << (a[0].sum(n - 1, n) ? "A" : "B") << endl; }