# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1055423 | makrav | Bomb (IZhO17_bomb) | C++17 | 38 ms | 13564 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second
void solve() {
int n, m; cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; i++) cin >> s[i];
int wg = m, hg = n;
for (int i = 0; i < n; i++) {
int lf = -1;
for (int j = 0; j < m; j++) {
if (s[i][j] == '1' && lf == -1) lf = j;
else if (s[i][j] == '0' && lf != -1) {
wg = min(wg, j - lf);
lf = -1;
}
}
if (lf != -1) wg = min(wg, m - lf);
}
for (int j = 0; j < m; j++) {
int lf = -1;
for (int i = 0; i < n; i++) {
if (s[i][j] == '1' && lf == -1) lf = i;
else if (s[i][j] == '0' && lf != -1) {
hg = min(hg, i - lf);
lf = -1;
}
}
if (lf != -1) hg = min(hg, n - lf);
}
cout << wg * hg << '\n';
}
signed main() {
int tt = 1;
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
cin >> tt;
#else
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#endif
while (tt--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |