제출 #1128743

#제출 시각아이디문제언어결과실행 시간메모리
1128743Noproblem29Bomb (IZhO17_bomb)C++20
100 / 100
327 ms76800 KiB
#include<bits/stdc++.h> using namespace std; #ifndef BADGNU #pragma GCC target("sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #endif #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ll long long // #define int ll #define ld long double #define y1 cheza mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>; const int N=2600; const int M=5001; const int B=447; const int mod=998244353; const ll INF=1e18; const int dx[]={1,-1,0,0}; const int dy[]={0,0,1,-1}; const double eps=1e-6; int n,m; int a[N][N]; int L[N][N],R[N][N]; int y[N]; void test(){ cin>>n>>m; for(int i=0;i<=n;i++){ y[i]=m+1; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ char x; cin>>x; a[i][j]=x-'0'; } } for(int i=1;i<=n;i++){ int cur=0; for(int j=1;j<=m;j++){ if(a[i][j]){ L[i][j]=L[i][j-1]+1; } else{ L[i][j]=0; } } for(int j=m;j>=1;j--){ if(a[i][j]){ R[i][j]=R[i][j+1]+1; } else{ R[i][j]=0; } } for(int j=1;j<=m;j++){ if(a[i][j]){ y[1]=min(y[1],L[i][j]+R[i][j]-1); } } } int x=n; for(int j=1;j<=m;j++){ int tl=m; int tr=m; int res=0; for(int i=1;i<=n;i++){ if(a[i][j]){ res++; tl=min(tl,L[i][j]); tr=min(tr,R[i][j]); y[res]=min(y[res],tr+tl-1); } else{ if(res>0){ x=min(x,res); } res=0; tl=m; tr=m; } } if(res>0){ x=min(x,res); } res=0; tl=m; tr=m; for(int i=n;i>=1;i--){ if(a[i][j]){ res++; tl=min(tl,L[i][j]); tr=min(tr,R[i][j]); y[res]=min(y[res],tr+tl-1); } else{ if(res>0){ x=min(x,res); } res=0; tl=m; tr=m; } } if(res>0){ x=min(x,res); } } int ans=0; for(int i=1;i<=x;i++){ y[i]=min(y[i-1],y[i]); ans=max(ans,i*y[i]); } cout<<ans<<'\n'; } /* */ signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr); int t2=1; // cin>>t2; for(int i=1;i<=t2;i++){ test(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...