# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
833458 | vjudge1 | Bomb (IZhO17_bomb) | C++17 | 254 ms | 6752 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
const ll N = 2600;
ll n,m;
char a[N][N];
ll mins,temp;
int main() {
cin >> n >> m;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
cin >> a[i][j];
}
}
mins = 1e9;
if(n == 1) {
if(a[1][1] == '1') temp++;
for(int i=2; i<=m; i++) {
if(a[1][i] == a[1][i-1] && a[1][i] == '1') {
temp++;
}
else {
if(temp != 0)mins = min(mins,temp);
if(a[1][i] == '0') temp = 0;
else temp = 1;
}
}
if(temp != 0)mins = min(mins,temp);
cout << mins << endl;
}
else if(m == 1) {
if(a[1][1] == '1') temp++;
for(int i=2; i<=n; i++) {
if(a[i][1] == a[i-1][1] && a[i][1] == '1') {
temp++;
}
else {
if(temp != 0)mins = min(mins,temp);
if(a[i][1] == '0') temp = 0;
else temp = 1;
}
}
if(temp != 0)mins = min(mins,temp);
cout << mins << endl;
}
else {
for(int i=1; i<=n; i++) {
if(a[i][1] == '1') temp++;
for(int j=2; j<=m; j++) {
if(a[i][j] == a[i][j-1] && a[i][j] == '1') {
temp++;
}
else {
// cout << "i " << i << " " << temp << endl;
if(temp != 0)mins = min(mins,temp);
if(a[i][j] == '0') temp = 0;
else temp = 1;
}
}
}
if(temp != 0)mins = min(mins,temp);
// cout << "temp " << mins << endl;
temp = 0;
ll mins1 = 1e9;
for(int i=1; i<=m; i++) {
if(a[1][i] == '1') temp++;
for(int j=2; j<=n; j++) {
if(a[j][i] == a[j-1][i] && a[j][i] == '1') {
temp++;
}
else {
// cout << "i " << i << " " << temp << endl;
if(temp != 0)mins1 = min(mins1,temp);
if(a[j][i] == '0') temp = 0;
else temp = 1;
}
}
}
if(temp != 0)mins1 = min(mins1,temp);
// cout << mins << " " << mins1 << endl;
cout << mins * mins1 << endl;
}
}
/*
10 1
0
0
0
1
1
0
0
1
1
1
9 1
011111011
5 6
001000
111110
111110
011110
000100
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |