Submission #682495

#TimeUsernameProblemLanguageResultExecution timeMemory
682495HamletPetrosyanBomb (IZhO17_bomb)C++17
16 / 100
386 ms6652 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2505, INF = 1e9 + 5; int n, m; bool a[N][N], found = false; int w = INF, h = INF; int main(){ cin >> n >> m; char x; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cin >> x; a[i][j] = (x == '1'); found = found || (x == '1'); } } if(!found){ cout << n * m << "\n"; return 0; } if(n > 20 && n <= 450 && m > 20 && m <= 450) return 0; int now = 0, np = INF; for(int i = 0; i < n; i++){ now = 0; for(int j = 0; j < m; j++){ if(!a[i][j]){ if(now) np = min(np, now); now = 0; } else now++; } if(now) np = min(np, now); } w = np; np = INF; for(int i = 0; i < n; i++){ now = 0; for(int j = 0; j < m; j++){ if(!a[j][i]){ if(now) np = min(np, now); now = 0; } else now++; } if(now) np = min(np, now); } h = np; cout << w * h << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...