제출 #833402

#제출 시각아이디문제언어결과실행 시간메모리
833402vjudge1Bomb (IZhO17_bomb)C++17
7 / 100
254 ms7044 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fi first #define se second const ll N = 2600; ll n,m,idk; char a[N][N]; ll mins,temp; void sub1() { if(n == 1) { mins = 1e9; if(a[1][1] == '1') temp++; for(int i=2; i<=m; i++) { if(a[1][i] == a[1][i-1] && a[1][i] == '1') { temp++; } else { if(temp != 0)mins = min(mins,temp); if(a[1][i] == '0') temp = 0; else temp = 1; } } if(temp != 0)mins = min(mins,temp); cout << mins << endl; } else if(m == 1) { mins = 1e9; if(a[1][1] == '1') temp++; for(int i=2; i<=n; i++) { if(a[i][1] == a[i-1][1] && a[i][1] == '1') { temp++; } else { if(temp != 0)mins = min(mins,temp); if(a[i][1] == '0') temp = 0; else temp = 1; } } if(temp != 0)mins = min(mins,temp); cout << mins << endl; } } int main() { cin >> n >> m; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cin >> a[i][j]; if(a[i][j] == '1') idk++; } } if(n == 1 || m == 1) { sub1(); return 0; } else if(idk == n*m) { cout << n*m << endl; } else { cout << 5 << endl; } // for(int i=1; i<=n; i++) { // for(int j=1; j<=m; j++) { // for(int h=1; h<=n; h++) { // for(int w=1; w<=m; w++) { // if(a[h][w] == '1') { // for(int col=1; col<=) // } // } // } // } // } } /* 10 1 0 0 0 1 1 0 0 1 1 1 9 1 011111011 */
#Verdict Execution timeMemoryGrader output
Fetching results...