제출 #1128721

#제출 시각아이디문제언어결과실행 시간메모리
1128721Noproblem29Bomb (IZhO17_bomb)C++20
19 / 100
94 ms32260 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; char a[N][N]; int pref[N][N]; int calc(int x1,int y1,int x2,int y2){ return pref[x2][y2]-pref[x1-1][y2]-pref[x2][y1-1]+pref[x1-1][y1-1]; } void test(){ cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; a[i][j]^=1; pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+a[i][j]-'0'; } } int x=2500; int y=2500; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='1')continue; if(a[i][j-1]=='0'||a[i-1][j]=='0')continue; int l=i; int r=n; while(l<=r){ int mid=(l+r)>>1ll; if(calc(i,j,mid,j)==0){ l=mid+1; } else{ r=mid-1; } } int x2=l-1; l=j; r=m; while(l<=r){ int mid=(l+r)>>1ll; if(calc(i,j,x2,mid)==0){ l=mid+1; } else{ r=mid-1; } } int y2=l-1; x=min(x,(x2-i+1)); y=min(y,(y2-j+1)); } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='1')continue; if(a[i][j-1]=='0'||a[i-1][j]=='0')continue; int l=j; int r=m; while(l<=r){ int mid=(l+r)>>1ll; if(calc(i,j,i,mid)==0){ l=mid+1; } else{ r=mid-1; } } int y2=l-1; l=i; r=n; while(l<=r){ int mid=(l+r)>>1ll; if(calc(i,j,mid,y2)==0){ l=mid+1; } else{ r=mid-1; } } int x2=l-1; x=min(x,(x2-i+1)); y=min(y,(y2-j+1)); } } cout<<x*y<<'\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...