# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833312 | vjudge1 | Bomb (IZhO17_bomb) | C++17 | 110 ms | 6604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 == INF && col == INF) cout << 0 << endl;
else cout << row << " " << col << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |