# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
833385 | vjudge1 | Bomb (IZhO17_bomb) | C++17 | 86 ms | 131072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<long long, long long>
#define loop(i,n) for(int i=1;i<=n;i++)
#define loop0(i,n) for(int i=0;i<n;i++)
using namespace std;
//pbds template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <class T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
void solve(){
ll n,m;
cin >> n >> m;
string a;
ll arr[n+m+5][n+m+5] = {0};
for(int i=1;i<=n;i++){
cin >> a;
for(int j=0;j<a.size();j++){
if(a[j]=='0'){
arr[i][j+1] = 0;
}
else{
arr[i][j+1] = 1;
}
}
}
ll pref[n+m+5][n+m+5] = {0};
ll pref2[n+m+5][n+m+5] = {0};
for(int i=1;i<=n;i++){
pref[i][0] = 0;
for(int j=1;j<=m;j++){
if(arr[i][j]==1){
pref[i][j] = pref[i][j-1]+1;
}
else{
pref[i][j] = 0;
}
}
}
for(int i=1;i<=m;i++){
pref2[0][i] = 0;
for(int j=1;j<=n;j++){
if(arr[j][i]==1){
pref2[j][i] = pref2[j-1][i]+1;
}
else{
pref2[j][i] = 0;
}
}
}
// cout << endl;
ll row = 1e18;
ll col = 1e18;
for(int i=1;i<=n;i++){
ll act = 0;
ll mn = 1e18;
ll temp = 0;
for(int j=1;j<=m;j++){
// cout << pref[i][j] << ' ';
if(act==0&&pref[i][j]!=0){
act = 1;
temp = max(temp,pref[i][j]);
}
if(act==1){
if(pref[i][j]==0){
mn = min(mn,temp);
act = 0;
temp = 0;
}
else{
temp = max(temp,pref[i][j]);
}
}
}
if(act==1){
mn = min(mn,temp);
}
row = min(row,mn);
// cout << endl;
}
// cout << endl;
for(int j=1;j<=m;j++){
ll act = 0;
ll mn = 1e18;
ll temp = 0;
for(int i=1;i<=n;i++){
// cout << pref2[i][j] << ' ';
if(act==0&&pref2[i][j]!=0){
act = 1;
temp = max(temp,pref2[i][j]);
}
if(act==1){
if(pref2[i][j]==0){
mn = min(mn,temp);
act = 0;
temp = 0;
}
else{
temp = max(temp,pref2[i][j]);
}
}
}
if(act==1){
mn = min(temp,mn);
}
col = min(col,mn);
// cout << endl;
}
if(row==1e18||col==1e18){
cout << '0' << endl;
return;
}
ll ans = row*col;
cout << ans << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tc = 1;
// cin >> tc;
while(tc--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |