結果

問題 No.2657 Falling Block Game
ユーザー maeshunmaeshun
提出日時 2024-03-03 18:31:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 1,715 bytes
コンパイル時間 4,613 ms
コンパイル使用メモリ 267,184 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-03-03 18:31:40
合計ジャッジ時間 10,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 30 ms
11,904 KB
testcase_05 AC 442 ms
7,784 KB
testcase_06 AC 177 ms
6,840 KB
testcase_07 AC 414 ms
7,784 KB
testcase_08 AC 163 ms
6,676 KB
testcase_09 AC 51 ms
11,904 KB
testcase_10 AC 163 ms
7,784 KB
testcase_11 AC 161 ms
7,784 KB
testcase_12 AC 174 ms
7,784 KB
testcase_13 AC 162 ms
7,784 KB
testcase_14 AC 161 ms
7,784 KB
testcase_15 AC 163 ms
7,784 KB
testcase_16 AC 164 ms
7,784 KB
testcase_17 AC 162 ms
7,784 KB
testcase_18 AC 160 ms
7,784 KB
testcase_19 AC 162 ms
7,784 KB
testcase_20 AC 67 ms
6,676 KB
testcase_21 AC 67 ms
6,676 KB
testcase_22 AC 68 ms
6,676 KB
testcase_23 AC 68 ms
6,676 KB
testcase_24 AC 68 ms
6,676 KB
testcase_25 AC 68 ms
6,676 KB
testcase_26 AC 67 ms
6,676 KB
testcase_27 AC 80 ms
6,676 KB
testcase_28 AC 67 ms
6,676 KB
testcase_29 AC 66 ms
6,676 KB
testcase_30 AC 54 ms
11,904 KB
testcase_31 AC 55 ms
11,904 KB
testcase_32 AC 54 ms
11,904 KB
testcase_33 AC 54 ms
11,904 KB
testcase_34 AC 54 ms
11,904 KB
testcase_35 AC 54 ms
11,904 KB
testcase_36 AC 53 ms
11,904 KB
testcase_37 AC 53 ms
11,904 KB
testcase_38 AC 54 ms
11,904 KB
testcase_39 AC 54 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int op(int a, int b) {
    return min(a,b);
}

int e(){
    return 1e9;
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> d(h, vector<int>(w));
    rep(j,w) d[h-1][j] = 0;
    for(int i=h-2;i>=0;i--){
        vector<int> l(w, -1), r(w, w);
        rep(j,w) {
            if(s[i][j]=='#') {
                l[j] = j;
            }
            if(j-1>=0) l[j] = max(l[j], l[j-1]);
        }
        for(int j=w-1;j>=0;j--){
            if(s[i][j]=='#') {
                r[j] = j;
            }
            if(j+1<w) r[j] = min(r[j], r[j+1]);
        }
        dbg(l,r);
        segtree<int, op, e> seg(d[i+1]); 
        rep(j,w){
            if(s[i][j]=='#') d[i][j] = 1e9;
            else{
                int high = w;
                int low = -1;
                while(high-low>1){
                    int mid = (high+low)/2;
                    int val = seg.prod(max(max(0, l[j]+1), j-mid), min(min(w, r[j]), j+mid+1));
                    if(val<=mid) high = mid;
                    else low = mid;
                }
                d[i][j] = high;
            }
        }
    }
    dbg(d);
    rep(j,w){
        cout << d[0][j] << "\n";
    }
    return 0;
}
0