제출 #1128775

#제출 시각아이디문제언어결과실행 시간메모리
1128775nurkeyevvBomb (IZhO17_bomb)C++20
0 / 100
100 ms6688 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back using namespace std; const int N = 2550; const int M = 100; const int mod1 = 998244353; const int mod = 998244353; const int inf = 1e18; char a[N][N]; void porsсhe(){ int n,m; cin >> n >> m; for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ cin >> a[i][j]; } } int cnt = 0,mn = inf,mn1 = inf; for(int i = 1;i <= n;i++){ cnt = 0; for(int j = 1;j <= m;j++){ if(a[i][j] == '1'){ cnt++; } else if(cnt >= 1){ mn = min(mn,cnt); cnt = 0; } } if(cnt != 0){ mn = min(mn,cnt); } } for(int i = 1;i <= m;i++){ int ans = 0; for(int j = 1;j <= n;j++){ if(a[j][i] == '1'){ ans++; } else if(ans >= 1){ mn1 = min(ans,mn1); ans = 0; } } if(ans != 0){ mn1 = min(mn1,ans); } } if(mn == inf && mn1 == inf){ cout << 0 << '\n'; return; } if(mn == inf || mn1 == inf){ cout << max(mn,mn1); return; } cout << mn << " " << mn1 << '\n'; // 3 3 // 1 1 // 3 3 // 4 4 // 1 1 // 3 3 // 0 0 // 3 3 // 2 2 } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; //cin >> tt; for(int i = 1;i <= tt;i++){ porsсhe(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...