# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
855382 | Alfraganus | Bomb (IZhO17_bomb) | C++17 | 120 ms | 55980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define print(a) \
for (auto x : a) \
cout << x << ' '; \
cout << endl;
#define printmp(a) \
for (auto x : a) \
cout << x.fs << ' ' << x.ss << endl;
void solve(){
int n, m;
cin >> n >> m;
vector<vector<char>> a(n, vector<char> (m));
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
cin >> a[i][j];
vector<vector<int>> dp_right(n, vector<int>(m)), dp_down(n, vector<int>(m));
for(int i = n - 1; i >= 0; i --){
for(int j = m - 1; j >= 0; j --){
if(a[i][j] == '1'){
dp_right[i][j] = (j == m - 1 ? 0 : dp_right[i][j + 1]) + 1;
dp_down[i][j] = (i == n - 1 ? 0 : dp_down[i + 1][j]) + 1;
}
else{
dp_right[i][j] = 0;
dp_down[i][j] = 0;
}
}
}
int x = m, y = n;
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
if(a[i][j] == '1'){
if(j == 0 or a[i][j - 1] == '0')
x = min(x, dp_right[i][j]);
if(i == 0 or a[i - 1][j] == '0')
y = min(y, dp_down[i][j]);
}
}
}
cout << x * y << endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
// freopen("bomb.in", "r", stdin);
// freopen("bomb.out", "w", stdout);
int t = 1;
// cin >> t;
while(t --){
solve();
cout << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |