結果
問題 | No.2657 Falling Block Game |
ユーザー | kwm_t |
提出日時 | 2024-03-02 17:46:14 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,906 bytes |
コンパイル時間 | 3,234 ms |
コンパイル使用メモリ | 257,652 KB |
実行使用メモリ | 11,948 KB |
最終ジャッジ日時 | 2024-09-29 16:24:00 |
合計ジャッジ時間 | 8,559 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 32 ms
11,776 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
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 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; //using mint = modint998244353; //const int mod = 998244353; //using mint = modint1000000007; //const int mod = 1000000007; const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } template<class S, S op(S l, S r), S e()> struct DualSegtree { private: int mn = 0; int mN = 0; int mlogN = 0; std::vector<S> A; void propagate(int i) { if (i >= mN) return; A[i * 2] = op(A[i * 2], A[i]); A[i * 2 + 1] = op(A[i * 2 + 1], A[i]); A[i] = e(); } void full_propagate(int i) { for (int d = mlogN; d > 0; d--) propagate(i >> d); } public: DualSegtree(int n = 0) { mn = n; mlogN = 0; mN = 1; while (mN < n) { mN *= 2; mlogN++; } A.assign(mN * 2, e()); } void point_init(int p) { assert(0 <= p); assert(p < mn); p += mN; full_propagate(p); A[p] = e(); } S get(int p) { assert(0 <= p); assert(p < mn); p += mN; full_propagate(p); return A[p]; } void apply(int l, int r, S x) { l += mN; r += mN; if (l != mN) full_propagate(l - 1); if (r != mN * 2) full_propagate(r); while (l < r) { if (l & 1) { A[l] = op(A[l], x); l++; } if (r & 1) { r--; A[r] = op(A[r], x); } l /= 2; r /= 2; } } }; //区間chmin、一点取得 using S = int; S op(S x, S f) { return std::min(x, f); } S e() { return { INF }; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<string>s(n); rep(i, n)cin >> s[i]; reverse(all(s)); vector dp(n, vector<int>(m, INF)); rep(i, m)if ('#' != s[0][i])dp[0][i] = 0; rep2(i, 1, n) { vector<int>lwall(m), rwall(m); lwall[0] = -1; rep(j, m) { if ('#' == s[i][j])lwall[j] = j; else if (0 != j)lwall[j] = lwall[j - 1]; } rwall[m - 1] = m; rrep(j, m) { if ('#' == s[i][j])rwall[j] = j; else if (j != m - 1)rwall[j] = rwall[j + 1]; } DualSegtree<S, op, e>segl(m); DualSegtree<S, op, e>segm(m); DualSegtree<S, op, e>segr(m); rep(j, m) { if ('#' == s[i - 1][j])continue; if ('#' == s[i][j])continue; {//左側val-i int l = lwall[j] + 1; int r = max(lwall[j] + 1, j - dp[i - 1][j]); if (l <= r) { //cout << "case0 " << l << " " << r << " " << j << endl; segl.apply(l, r, j); } } {//真ん中val int l = max(lwall[j] + 1, j - dp[i - 1][j]); int r = min(rwall[j], j + dp[i - 1][j] + 1); if (l <= r) { //cout << "case1 " << l << " " << r << " " << j << endl; segm.apply(l, r, dp[i - 1][j]); } } {// 右val+j int l = min(rwall[j], j + dp[i - 1][j] + 1); int r = rwall[j]; if (l <= r) { //cout << "case2 " << l << " " << r << " " << j << endl; segr.apply(l, r, -j); } } } /*cout << "seg" << endl; rep(j, m) { cout << segl.get(j) << " "; }cout << endl; rep(j, m) { cout << segm.get(j) << " "; }cout << endl; rep(j, m) { cout << segr.get(j) << " "; }cout << endl; cout << endl;*/ rep(j, m) { { auto get = segl.get(j); if (INF != abs(get))chmin(dp[i][j], segl.get(j) - j); } { auto get = segm.get(j); if (INF != abs(get))chmin(dp[i][j], segm.get(j)); } { auto get = segr.get(j); if (INF != abs(get))chmin(dp[i][j], segr.get(j) + j); } } } rep(j, m)cout << dp.back()[j] << " "; cout << endl; return 0; } /* 5 8 22233333 2######3 21000123 ##000### 00000000 */