Submission #833729

#TimeUsernameProblemLanguageResultExecution timeMemory
833729vjudge1Bomb (IZhO17_bomb)C++17
19 / 100
124 ms6552 KiB
#include<bits/stdc++.h>
using namespace std;

#define For(i, n) for (int i = 0; i < n; i++)
#define pb push_back

const int INF = INT_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int N, M; cin >> N >> M;
	char grid[N][M];
	For (i, N) For (j, M) cin >> grid[i][j];
	int row = INF, col = INF;
	For (i, N) {
		vector <int> one;
		For (j, M) {
			if (grid[i][j] == '1') 
				one.pb(j);
		}
		if (one.empty()) continue;
		one.pb(-1);
		int cnt = 1;
		for (int j = 1; j < (int) one.size(); j++) {
			if (one[j] == one[j - 1] + 1) cnt++;
			else {
				row = min(row, cnt);
				cnt = 1;
			}
		}
	}
	For (j, M) {
		vector <int> one;
		For (i, N) {
			if (grid[i][j] == '1') {
				one.pb(i);
			}
		}
		if (one.empty()) continue;
		one.pb(-1);
		int cnt = 1;
		for (int j = 1; j < (int) one.size(); j++) {
			if (one[j] == one[j - 1] + 1) cnt++;
			else {
				col = min(col, cnt);
				cnt = 1;
			}
		}
	}
	if (row == col) row--;
	cout << row * col << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...