結果
| 問題 | No.2657 Falling Block Game | 
| コンテスト | |
| ユーザー |  sotanishy | 
| 提出日時 | 2024-03-01 22:05:17 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,134 bytes | 
| コンパイル時間 | 3,088 ms | 
| コンパイル使用メモリ | 259,028 KB | 
| 実行使用メモリ | 12,180 KB | 
| 最終ジャッジ日時 | 2024-09-29 14:01:04 | 
| 合計ジャッジ時間 | 9,010 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 RE * 22 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define revrep(i, t, s) for (int i = (int)(t)-1; i >= (int)(s); --i)
#define all(x) begin(x), end(x)
template <typename T>
bool chmax(T& a, const T& b) {
    return a < b ? (a = b, 1) : 0;
}
template <typename T>
bool chmin(T& a, const T& b) {
    return a > b ? (a = b, 1) : 0;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (auto& row : S) cin >> row;
    vector<int> dp(W, 0);
    const int INF = 1e9;
    revrep(i, H, 0) {
        vector<int> ndp(W, INF);
        vector<vector<int>> diff(W);
        multiset<int> st;
        int left = -1;
        rep(j, 0, W) {
            if (S[i][j] == '#') {
                st.clear();
                left = -1;
                continue;
            }
            st.insert(dp[j]);
            if (j + dp[j] < W) {
                diff[j + dp[j]].push_back(j);
            }
            if (!st.empty()) {
                chmin(ndp[j], *st.begin());
            }
            if (left != -1) {
                chmin(ndp[j], j - left);
            }
            for (int k : diff[j]) {
                st.erase(st.find(dp[k]));
                chmax(left, k);
            }
            diff[j].clear();
        }
        st.clear();
        int right = W;
        revrep(j, W, 0) {
            if (S[i][j] == '#') {
                st.clear();
                right = W;
                continue;
            }
            st.insert(dp[j]);
            if (j - dp[j] >= 0) {
                diff[j - dp[j]].push_back(j);
            }
            if (!st.empty()) {
                chmin(ndp[j], *st.begin());
            }
            if (right != W) {
                chmin(ndp[j], right - j);
            }
            for (int k : diff[j]) {
                st.erase(st.find(dp[k]));
                chmin(right, k);
            }
        }
        dp.swap(ndp);
    }
    rep(j, 0, W) cout << dp[j] << "\n";
}
            
            
            
        