# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145505 | MladenP | Bomb (IZhO17_bomb) | C++17 | 112 ms | 18936 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>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
string s[2510];
int N, M;
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
cin >> N >> M;
s[0] = string(M+2, '0');
for(int i = 1; i <= N; i++) {
cin >> s[i];
s[i] = '0' + s[i] + '0';
}
s[N+1] = string(M+2, '0');
int cur = 0, najmX = INF, najmY = INF;
for(int i = 1; i <= N; i++) {
for(int j = 1; j <= M+1; j++) {
if(s[i][j] == '1') cur++;
if(s[i][j] == '0' && s[i][j-1] == '1') najmX = min(najmX, cur);
if(s[i][j] == '0') cur = 0;
}
}
cur = 0;
for(int j = 1; j <= M; j++) {
for(int i = 1; i <= N+1; i++) {
if(s[i][j] == '1') cur++;
if(s[i][j] == '0' && s[i-1][j] == '1') najmY = min(najmY, cur);
if(s[i][j] == '0') cur = 0;
}
}
cout << najmX*najmY;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |