# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168978 | abil | Bomb (IZhO17_bomb) | C++14 | 1099 ms | 105856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long
using namespace std;
const int N = (2500 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);
char a[N][N];
int up[N][N], down[N][N], leftt[N][N], rightt[N][N];
int n, m;
bool solve(int x,int y){
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
if(a[i][j] == '1'){
if((up[i][j] + down[i][j] - 1 < x || leftt[i][j] + rightt[i][j] - 1 < y) && (up[i][j] + down[i][j] - 1 < y || leftt[i][j] + rightt[i][j] - 1 < x)){
return false;
}
}
}
}
return true;
}
main()
{
cin >> n >> m;
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
cin >> a[i][j];
}
}
int mnx = INF, mny = INF;
for(int i = 1;i <= n; i++){
int cnt = 0;
for(int j = 1;j <= m; j++){
cnt = (a[i][j] == '0' ? 0 : cnt + 1);
leftt[i][j] = cnt;
mny = min(mny, leftt[i][j]);
}
}
for(int i = 1;i <= n; i++){
int cnt = 0;
for(int j = m;j >= 1; j--){
cnt = (a[i][j] == '0' ? 0 : cnt + 1);
rightt[i][j] = cnt;
mny = min(mny, rightt[i][j]);
}
}
for(int i = 1;i <= m; i++){
int cnt = 0;
for(int j = 1;j <= n; j++){
cnt = (a[j][i] == '0' ? 0 : cnt + 1);
up[j][i] = cnt;
mnx = min(mnx, up[j][i]);
}
}
for(int i = 1;i <= m; i++){
int cnt = 0;
for(int j = n;j >= 1; j--){
cnt = (a[j][i] == '0' ? 0 : cnt + 1);
down[j][i] = cnt;
}
}
int ans = 1;
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
if(solve(i,j)){
ans = max(ans, i * j);
}
}
}
cout << ans;
}
/*
6 6
000100
000100
111111
000010
000010
000010
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |