結果

問題 No.2657 Falling Block Game
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2024-03-01 23:09:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,943 bytes
コンパイル時間 3,415 ms
コンパイル使用メモリ 260,184 KB
実行使用メモリ 16,868 KB
最終ジャッジ日時 2024-03-01 23:09:30
合計ジャッジ時間 10,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 28 ms
6,676 KB
testcase_05 AC 267 ms
16,352 KB
testcase_06 AC 247 ms
10,160 KB
testcase_07 AC 208 ms
11,692 KB
testcase_08 AC 97 ms
6,676 KB
testcase_09 AC 85 ms
6,676 KB
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 AC 115 ms
6,676 KB
testcase_31 AC 89 ms
6,676 KB
testcase_32 AC 90 ms
6,676 KB
testcase_33 AC 89 ms
6,676 KB
testcase_34 AC 89 ms
6,676 KB
testcase_35 AC 90 ms
6,676 KB
testcase_36 AC 90 ms
6,676 KB
testcase_37 AC 87 ms
6,676 KB
testcase_38 AC 89 ms
6,676 KB
testcase_39 AC 85 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h,w;
    cin >> h >> w;
    vector<string> S(h);
    for (auto &s: S) cin >> s;

    vector<int> dp(w,0);

    const int INF = 1e9;
    for (int i = h-2; i >= 0; i--){

        vector<int> ndp(w,INF);

        vector<vector<pair<int,int>>> event(w);

        for (int x = 0; x < w; x++){
            int cost = dp[x];
            event[max(0,x-cost)].push_back({cost,1});
        }
        for (int x = 0; x < w; x++){
            event[x].push_back({x,0});
        }

        for (int x = 0; x < w; x++){
            int cost = dp[x];
            event[min(w-1,x+cost)].push_back({cost,-1});
        }

        multiset<int> ms;
        ms.insert(INF);

        for (int x = 0; x < w; x++){

            for (auto [c,t] : event[x]){
                if (t == 1) {
                    ms.insert(c);
                } else if (t == 0){

                    ndp[c] = *ms.begin();

                } else{
                    auto it = ms.find(c);

                    // イテレータがマルチセットの終端でない、つまり要素が見つかった場合、その要素を削除
                    if (it != ms.end()) {
                        ms.erase(it);
                    } else{
                        assert (0);
                    }
                }
                
            }
        }

        for (int x = 1; x < w; x++){
            ndp[x] = min(ndp[x],ndp[x-1]+1);
        }
        for (int x = w-2;x >= 0; x--){
            ndp[x] = min(ndp[x],ndp[x+1]+1);
        }

        for (int x = 0;x < w; x++){
            if (S[i][x] == '#'){
                ndp[x] = INF;
            }
            if (i > 0 && S[i-1][x] != '.'){
                ndp[x] = INF;
            }
        }
        swap(dp,ndp);
    }

    for (auto a: dp){
        cout << a << endl;
    }




    return 0;
}
0