結果
問題 | No.2657 Falling Block Game |
ユーザー | SnowBeenDiding |
提出日時 | 2024-03-01 22:32:24 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,416 bytes |
コンパイル時間 | 4,945 ms |
コンパイル使用メモリ | 325,136 KB |
実行使用メモリ | 12,656 KB |
最終ジャッジ日時 | 2024-09-29 14:33:23 |
合計ジャッジ時間 | 10,799 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 44 ms
11,892 KB |
testcase_05 | AC | 222 ms
12,524 KB |
testcase_06 | AC | 158 ms
9,276 KB |
testcase_07 | AC | 246 ms
12,648 KB |
testcase_08 | AC | 93 ms
6,816 KB |
testcase_09 | AC | 89 ms
11,904 KB |
testcase_10 | AC | 190 ms
12,652 KB |
testcase_11 | AC | 190 ms
12,652 KB |
testcase_12 | AC | 193 ms
12,652 KB |
testcase_13 | AC | 192 ms
12,648 KB |
testcase_14 | AC | 193 ms
12,524 KB |
testcase_15 | AC | 188 ms
12,652 KB |
testcase_16 | AC | 189 ms
12,652 KB |
testcase_17 | AC | 193 ms
12,652 KB |
testcase_18 | AC | 189 ms
12,652 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 90 ms
12,032 KB |
testcase_31 | AC | 90 ms
11,904 KB |
testcase_32 | AC | 90 ms
11,776 KB |
testcase_33 | AC | 90 ms
11,764 KB |
testcase_34 | AC | 89 ms
11,876 KB |
testcase_35 | AC | 88 ms
11,752 KB |
testcase_36 | AC | 87 ms
11,904 KB |
testcase_37 | AC | 87 ms
11,904 KB |
testcase_38 | AC | 90 ms
11,784 KB |
testcase_39 | AC | 88 ms
11,904 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace std; using namespace atcoder; typedef long long ll; const int inf = 1e9; struct RMUQ { using S = ll; using F = ll; public: RMUQ() : RMUQ(0) {} RMUQ(int n) : RMUQ(std::vector<S>(n, e())) {} RMUQ(const std::vector<S>& v) : _n(int(v.size())) { log = ceil_pow2(_n); size = 1 << log; d = std::vector<S>(2 * size, e()); lz = std::vector<F>(size, id()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return d[p]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); if (l == r) return e(); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push(r >> i); } S sml = e(), smr = e(); while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } void apply(int p, F f) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = mapping(f, d[p]); for (int i = 1; i <= log; i++) update(p >> i); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } { int l2 = l, r2 = r; while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } l = l2; r = r2; } for (int i = 1; i <= log; i++) { if (((l >> i) << i) != l) update(l >> i); if (((r >> i) << i) != r) update((r - 1) >> i); } } S op(S a, S b) { return min(a, b); } S e() { return 1e18; } S mapping(F f, S x) { return f != id() ? f : x; } F composition(F f, F g) { return f != id() ? f : g; } F id() { return -1e18; } int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } ll operator[](int i) { return get(i); } void out() { for (int i = 0; i < _n; i++) cout << get(i) << " \n"[i == _n - 1]; } void err() { for (int i = 0; i < _n; i++) cerr << get(i) << " \n"[i == _n - 1]; } private: int _n, size, log; std::vector<S> d; std::vector<F> lz; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } void all_apply(int k, F f) { d[k] = mapping(f, d[k]); if (k < size) lz[k] = composition(f, lz[k]); } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; vector<int> f(vector<int> a, string s) { int n = a.size(); vector<int> ret(n); RMUQ rsuq(n); vector<pair<int, int>> ord; rep(i, 0, n) ord.emplace_back(a[i], i); sort(ord.rbegin(), ord.rend()); vector<int> lb(n), rb(n); int id = 0; rep(i, 0, n) { if (s[i] == '#') id = i + 1; lb[i] = id; } id = n - 1; for (int i = n - 1; i >= 0; i--) { if (s[i] == '#') id = i - 1; rb[i] = id; } rep(i, 0, n) { int idx = ord[i].second; if (s[idx] == '#') continue; int l = max({0, idx - a[idx], lb[idx]}); int r = min({n, idx + a[idx] + 1, rb[idx] + 1}); if (l < r) rsuq.apply(l, r, a[idx]); } rep(i, 0, n) { ll nw = rsuq.get(i); if (nw >= 1e18 / 2) ret[i] = inf; else ret[i] = nw; } vector<int> l(n, inf), r(n, inf); rep(i, 1, n) { if (ret[i] >= inf / 2 && s[i - 1] != '#') { l[i] = min(ret[i - 1] + 1, l[i - 1] + 1); } } for (int i = n - 2; i >= 0; i--) { if (ret[i] >= inf / 2 && s[i + 1] != '#') { r[i] = min(ret[i + 1] + 1, r[i + 1] + 1); } } rep(i, 0, n) ret[i] = min({ret[i], l[i], r[i]}); rep(i, 0, n) if (s[i] == '#') ret[i] = inf; return ret; } int main() { int h, w; cin >> h >> w; vector<string> s(h); rep(i, 0, h) cin >> s[i]; vector<vector<int>> dp(h, vector<int>(w, 0)); for (int i = h - 2; i >= 0; i--) { auto v = f(dp[i + 1], s[i]); rep(j, 0, w) dp[i][j] = v[j]; } // rep(i, 0, h) { // rep(j, 0, w) { // if (dp[i][j] >= inf / 2) // cerr << "x "; // else // cerr << dp[i][j] << " "; // } // cerr << endl; // } rep(i, 0, w) cout << dp[0][i] << endl; }