結果
問題 | No.2657 Falling Block Game |
ユーザー |
![]() |
提出日時 | 2025-01-11 19:44:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,936 bytes |
コンパイル時間 | 5,963 ms |
コンパイル使用メモリ | 307,644 KB |
実行使用メモリ | 11,864 KB |
最終ジャッジ日時 | 2025-01-11 19:45:07 |
合計ジャッジ時間 | 7,743 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 20 |
ソースコード
#ifdef t9unkubj#include"debug.cpp"//#include"template_no_debug.h"#else#define dbg(...) 199958#endif#undef _GLIBCXX_DEBUG#pragma GCC optimize("O3")using namespace std;#include<bits/stdc++.h>using ll=long long;using ull=unsigned long long;template<class T>using vc=vector<T>;template<class T>using vvc=vc<vc<T>>;#define rep(i,n) for(ll i=0;i<(ll)(n);i++)#define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++)#define DREP(i,n,m) for(ll i=(n);i>=(m);i--)#define drep(i,n) for(ll i=((n)-1);i>=0;i--)#define all(x) x.begin(),x.end()#define rall(x) x.rbegin(),x.rend()template<class T,class F>bool chmin(T &x, F y){if(x>y){x=y;return true;}return false;}template<class T, class F>bool chmax(T &x, F y){if(x<y){x=y;return true;}return false;}double pass_time=0;#include<vector>#include<functional>template<class T>struct sparse_table{std::vector<std::vector<T>>data;std::vector<int>table;using F=std::function<T(T,T)>;F op;vector<T>a;int n;sparse_table()=default;sparse_table(int n,F op):n(n),a(n),op(op){}sparse_table(int n,std::vector<T>a,F op):n(n),op(op),a(a){build();}void set(int i,T x){a[i]=x;}void build(){int log{1};while((1<<log)<=n)log++;data=std::vector<vector<T>>(log,std::vector<T>(n));data[0]=a;for(int i=1;i<log;i++){for(int j=0;j<n;j++){if(j+(1<<(i-1))<n)data[i][j]=op(data[i-1][j],data[i-1][j+(1<<(i-1))]);}}table.resize(n+1);for(int i=1;i<=n;i++){for(int j=0;j<=log+1;j++){if((1<<j)<=i){table[i]=j;}}}}//[l,r)T prod(int l,int r){int len=r-l;int lg=table[len];return op(data[lg][l],data[lg][r-(1<<lg)]);}};void solve(){int h,w;cin>>h>>w;vc<string>s(h);rep(i,h)cin>>s[i];auto op=[&](int a,int b){return min(a,b);};sparse_table<int> dp(w,op);rep(j,w){if(s[h-1][j]=='.'&&s[h-2][j]=='.'){dp.set(j,0);}else dp.set(j,1e9);}drep(i,h-1){dp.build();sparse_table<int>ndp(w,op);rep(j,w){if(s[i][j]=='.'){int ac=w,wa=-1;while(ac-wa>1){int wj=ac+wa>>1;int l=max(0ll,j-wj);int r=min<ll>(w,j+wj+1);if(dp.prod(l,r)<=wj){ac=wj;}else wa=wj;}ndp.set(j,ac);}else ndp.set(j,1e9);}dp=move(ndp);if(i){rep(j,w)if(s[i-1][j]=='#')dp.set(j,1e9);}}rep(i,w){cout<<dp.a[i]<<"\n";}}signed main(){cin.tie(0)->sync_with_stdio(0);pass_time=clock();int t=1;//cin>>t;while(t--)solve();pass_time=clock()-pass_time;dbg(pass_time/CLOCKS_PER_SEC);}