제출 #1166904

#제출 시각아이디문제언어결과실행 시간메모리
1166904omar1312Bomb (IZhO17_bomb)C++20
0 / 100
35 ms19592 KiB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
const int mod = 1000000007;
const int N = 200005;
string a[N+2], dp[N+2];
void solve(){
    int n, m;
    cin>>n>>m;
    int r = n, c = m;
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    for(int i = 0; i < n; i++){
        int cnt = 0;
        for(int j = 0; j < m; j++){
            cnt += a[i][j] == '1';
            if(a[i][j] == '0'){
                if(cnt)c = min(c, cnt);
                cnt = 0;
            }
        }
        if(cnt)c = min(c, cnt);
    }
    for(int j = 0; j < m; j++){
        int cnt = 0;
        for(int i = 0; i < n; i++){
            cnt += a[i][j] == '1';
            if(a[i][j] == '0'){
                if(cnt)r = min(r, cnt);
                cnt = 0;
            }
        }
        if(cnt)r = min(r, cnt);
    }
    cout<<r<<" "<<c;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    //cin>>tt;
    while(tt--){
        solve();
        cout<<'\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...