Submission #1128723

#TimeUsernameProblemLanguageResultExecution timeMemory
1128723VietnowBomb (IZhO17_bomb)C++20
24 / 100
129 ms49392 KiB
#include <bits/stdc++.h> #define yes cout<<"YES\n" #define no cout<<"NO\n" #define int long long #define ff first #define ss second #define pb push_back #define y1 zildjian #define left radio #define right head using namespace std; const int N = 2501; const int INF = 1e18; const int mod = 1e9+7; const int mod1 = 998244353; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n,m; int a[N][N]; void solve(){ cin>>n>>m; for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ char x; cin>>x; a[i][j] = x-'0'; } } int mn1 = m; for(int i = 1;i<=n;i++){ int lst = 0; for(int j = 1;j<=m;j++){ if(a[i][j] == 0){ if(lst+1 != j){ mn1 = min(mn1,j-lst-1); } lst = j; } } if(lst+1 != m+1){ mn1 = min(mn1,(m+1)-lst-1); } } int mn2 = n; for(int j = 1;j<=m;j++){ int lst = 0; for(int i = 1;i<=n;i++){ if(a[i][j] == 0){ if(lst+1 != i){ // cout<<lst<<' '<<i<<' '<<j<<'\n'; mn2 = min(mn2,i-lst-1); } lst = i; } } if(lst+1 != n+1){ mn2 = min(mn2,(n+1)-lst-1); } } cout<<mn1*mn2<<'\n'; } signed main(){ // freopen("bootfall.in","r",stdin); // freopen("bootfall.out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(nullptr); // cout.tie(nullptr); int t = 1; // cin>>t; for(int i = 1;i<=t;i++){ // cout<<"Case "<<i<<": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...