답안 #442588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
442588 2021-07-08T08:41:25 Z leaked Bomb (IZhO17_bomb) C++14
100 / 100
115 ms 80084 KB
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define vec vector
#define sz(x) ( int)x.size()
#define m_p make_pair
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

typedef long long ll;
typedef pair<ll, int> pli;
typedef pair< int,ll> pil;
typedef pair< int, int> pii;
auto rng=bind(uniform_int_distribution< int>(1,32000),mt19937(time(0)));
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
const  int N=2503;
 int up[N][N],dn[N][N],n,m;
int a[N][N];
int tt;
int lst[N],mxm[N];
 int fck[N];
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for( int i=1;i<=n;i++){
        string s;
        cin>>s;
        for( int j=0;j<m;j++){
            a[i][j+1]=s[j]-'0';
        }
    }
    for(int i=1;i<=m;i++){
        mxm[i]=1e9;
    }
    for( int i=n;i>=1;i--){
        for( int j=m;j>=1;j--){
            if(a[i][j]) dn[i][j]=dn[i+1][j]+1;
        }
    }
    for( int i=1;i<=n;i++){
        for( int j=m;j>=1;j--){
            if(a[i][j]) up[i][j]=up[i-1][j]+1,umin(mxm[1],up[i][j]+dn[i][j]-1);;
        }
    }
    for(int rep=0;rep<2;rep++){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(!a[i][j]) continue;
            int r=j;
            while(a[i][r]) r++;
            int f=n,s=n;

            for(int k=1;k<=r-j;k++){
                umin(f,up[i][j+k-1]);
                umin(s,dn[i][j+k-1]);
//                cerr<<k<<' '<<f+s<<endl;
                umin(mxm[k],f+s-1);
            }
            umin(mxm[r-j+1],0);
            j=r;
        }
    }
    for(int i=1;i<=n;i++){
        reverse(up[i]+1,up[i]+m+1);
        reverse(dn[i]+1,dn[i]+m+1);
        reverse(a[i]+1,a[i]+m+1);
    }
    }
    for( int i=2;i<=m;i++) umin(mxm[i],mxm[i-1]);
    int ans=0;
    for( int i=1;i<=m;i++){
        umax(ans,i*mxm[i]);
    }
    cout<<ans;
    return 0;
}

/*
10
2 1 2 2 1 1 3 2 5 5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 252 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 15 ms 30344 KB Output is correct
4 Correct 15 ms 30408 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 472 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1228 KB Output is correct
19 Correct 1 ms 1484 KB Output is correct
20 Correct 1 ms 1484 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 1356 KB Output is correct
23 Correct 1 ms 1612 KB Output is correct
24 Correct 1 ms 1356 KB Output is correct
25 Correct 2 ms 1612 KB Output is correct
26 Correct 1 ms 1612 KB Output is correct
27 Correct 4 ms 4812 KB Output is correct
28 Correct 5 ms 5320 KB Output is correct
29 Correct 5 ms 6604 KB Output is correct
30 Correct 6 ms 7884 KB Output is correct
31 Correct 5 ms 6220 KB Output is correct
32 Correct 6 ms 7116 KB Output is correct
33 Correct 6 ms 8268 KB Output is correct
34 Correct 4 ms 5580 KB Output is correct
35 Correct 7 ms 8268 KB Output is correct
36 Correct 7 ms 8268 KB Output is correct
37 Correct 1 ms 580 KB Output is correct
38 Correct 109 ms 79852 KB Output is correct
39 Correct 1 ms 588 KB Output is correct
40 Correct 20 ms 20572 KB Output is correct
41 Correct 1 ms 588 KB Output is correct
42 Correct 1 ms 1612 KB Output is correct
43 Correct 101 ms 79848 KB Output is correct
44 Correct 7 ms 8268 KB Output is correct
45 Correct 101 ms 79928 KB Output is correct
46 Correct 99 ms 79960 KB Output is correct
47 Correct 103 ms 79940 KB Output is correct
48 Correct 102 ms 79944 KB Output is correct
49 Correct 106 ms 79936 KB Output is correct
50 Correct 103 ms 79936 KB Output is correct
51 Correct 103 ms 80000 KB Output is correct
52 Correct 99 ms 79892 KB Output is correct
53 Correct 102 ms 79928 KB Output is correct
54 Correct 96 ms 79932 KB Output is correct
55 Correct 95 ms 79944 KB Output is correct
56 Correct 112 ms 79912 KB Output is correct
57 Correct 95 ms 79904 KB Output is correct
58 Correct 97 ms 79940 KB Output is correct
59 Correct 97 ms 79940 KB Output is correct
60 Correct 105 ms 79932 KB Output is correct
61 Correct 107 ms 79896 KB Output is correct
62 Correct 108 ms 79936 KB Output is correct
63 Correct 115 ms 79880 KB Output is correct
64 Correct 105 ms 79940 KB Output is correct
65 Correct 107 ms 80012 KB Output is correct
66 Correct 101 ms 79916 KB Output is correct
67 Correct 111 ms 79952 KB Output is correct
68 Correct 107 ms 79900 KB Output is correct
69 Correct 101 ms 79916 KB Output is correct
70 Correct 69 ms 63040 KB Output is correct
71 Correct 97 ms 79888 KB Output is correct
72 Correct 102 ms 79952 KB Output is correct
73 Correct 99 ms 79952 KB Output is correct
74 Correct 100 ms 79924 KB Output is correct
75 Correct 95 ms 80016 KB Output is correct
76 Correct 99 ms 79940 KB Output is correct
77 Correct 98 ms 80084 KB Output is correct
78 Correct 100 ms 79860 KB Output is correct
79 Correct 92 ms 79940 KB Output is correct
80 Correct 95 ms 79976 KB Output is correct
81 Correct 97 ms 79896 KB Output is correct
82 Correct 104 ms 79956 KB Output is correct
83 Correct 101 ms 79884 KB Output is correct
84 Correct 94 ms 79964 KB Output is correct
85 Correct 102 ms 79940 KB Output is correct
86 Correct 104 ms 79924 KB Output is correct
87 Correct 99 ms 79880 KB Output is correct
88 Correct 99 ms 79940 KB Output is correct
89 Correct 100 ms 79940 KB Output is correct
90 Correct 73 ms 62972 KB Output is correct
91 Correct 101 ms 79940 KB Output is correct
92 Correct 100 ms 79884 KB Output is correct
93 Correct 104 ms 79880 KB Output is correct
94 Correct 101 ms 79940 KB Output is correct
95 Correct 101 ms 80016 KB Output is correct
96 Correct 112 ms 79876 KB Output is correct
97 Correct 113 ms 79916 KB Output is correct
98 Correct 106 ms 79844 KB Output is correct
99 Correct 102 ms 79940 KB Output is correct
100 Correct 109 ms 79956 KB Output is correct