Submission #915532

# Submission time Handle Problem Language Result Execution time Memory
915532 2024-01-24T06:30:24 Z vjudge1 Bomb (IZhO17_bomb) C++17
29 / 100
1000 ms 51196 KB
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define str string
#define pii pair<int,int>
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mii map<int,int>
#define mll map<ll,ll>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yess cout<<"Yes\n";
#define noo cout<<"No\n";
using namespace std;

int pp[101][101];
int u[101][101];

void solve(){
    int n,m;
    cin>>n>>m;
    if(n==1){
        str s;
        cin>>s;
        vector<int >v;
        int k=0;
        for(int i=0;i<m;i++){
            if(s[i]=='1')k++;
            else{
                if(k>0){
                    v.pb(k);
                    k=0;
                }
            }
        }
        if(k>0){
            v.pb(k);
        }
        int ans=1;
        if(v.size()==0){
            cout<<0;
            return;
        }
        for(int i=2;i<=m;i++){
            k=1;
            for(int j=0;j<(int)v.size();j++){
                if(v[j]<i){
                    k=0;
                    break;
                }
            }
            if(k==1){
                ans=i;
            }
        }
        cout<<ans;
    }
    else if(m==1){
        char s;
        vector<int >v;
        int k=0;
        for(int i=0;i<n;i++){
            cin>>s;
            if(s=='1')k++;
            else{
                if(k>0){
                    v.pb(k);
                    k=0;
                }
            }
        }
        if(k>0){
            v.pb(k);
        }
        int ans=1;
        if(v.size()==0){
            cout<<0;
            return;
        }
        for(int i=2;i<=n;i++){
            k=1;
            for(int j=0;j<(int)v.size();j++){
                if(v[j]<i){
                    k=0;
                    break;
                }
            }
            if(k==1){
                ans=i;
            }
        }
        cout<<ans;
    }
    else{
        str s[n+3];
        int a[n+3][m+3];
        int o=0;
        for(int i=1;i<=n;i++){
            cin>>s[i];
            for(int j=0;j<m;j++){
                a[i][j+1]=s[i][j]-'0';
                o+=(a[i][j]==1);
                pp[i][j+1]=a[i][j+1]+pp[i][j]+pp[i-1][j+1]-pp[i-1][j];
            }
        }
        if(o==0){
            cout<<0;
            return;
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(i*j<=ans){
                    continue;
                }
                for(int i1=1;i1<=n;i1++){
                    for(int j1=1;j1<=m;j1++){
                        u[i1][j1]=0;
                    }
                }
                for(int i1=1;i1<=n;i1++){
                    for(int j1=1;j1<=m;j1++){
                        if(i1+i-1>n || j1+j-1>m)continue;
                        if(pp[i1+i-1][j1+j-1]+pp[i1-1][j1-1]-pp[i1+i-1][j1-1]-pp[i1-1][j1+j-1]==i*j){
                            for(int i2=i1;i2<=i1+i-1;i2++){
                                for(int j2=j1;j2<=j1+j-1;j2++){
                                    u[i2][j2]=1;
                                }
                            }
                        }
                    }
                }
                int k=1;
                for(int i1=1;i1<=n;i1++){
                    for(int j1=1;j1<=m;j1++){
                        if(u[i1][j1]!=a[i1][j1]){
                            k=0;
                            break;
                        }
                    }
                }
                if(k==1){
                    /*cout<<i<<" "<<j<<"\n";
                    for(int i1=1;i1<=n;i1++){
                        for(int j1=1;j1<=m;j1++){
                            cout<<u[i1][j1];
                        }
                        cout<<"\n";
                    }//*/
                    ans=max(ans,i*j);
                }
            }
        }
        cout<<ans;
    }
}

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	//srand( time(0));
	//rand()
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
    int tests=1;
    //cin>>tests;
    for(int i=1;i<=tests;i++){
		//cout<<"TEST CASE : "<<i<<"\n";
		solve();
	}
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 38 ms 348 KB Output is correct
18 Correct 31 ms 344 KB Output is correct
19 Correct 87 ms 552 KB Output is correct
20 Correct 95 ms 556 KB Output is correct
21 Correct 36 ms 348 KB Output is correct
22 Correct 80 ms 348 KB Output is correct
23 Correct 157 ms 564 KB Output is correct
24 Correct 58 ms 344 KB Output is correct
25 Correct 215 ms 600 KB Output is correct
26 Execution timed out 1068 ms 348 KB Time limit exceeded
27 Runtime error 1 ms 1372 KB Execution killed with signal 11
28 Runtime error 2 ms 1628 KB Execution killed with signal 11
29 Runtime error 2 ms 1628 KB Execution killed with signal 11
30 Runtime error 2 ms 2140 KB Execution killed with signal 11
31 Runtime error 2 ms 1884 KB Execution killed with signal 11
32 Runtime error 2 ms 1884 KB Execution killed with signal 11
33 Runtime error 2 ms 2396 KB Execution killed with signal 11
34 Runtime error 1 ms 1372 KB Execution killed with signal 11
35 Runtime error 2 ms 2396 KB Execution killed with signal 11
36 Runtime error 2 ms 2424 KB Execution killed with signal 11
37 Correct 1 ms 348 KB Output is correct
38 Runtime error 34 ms 50824 KB Execution killed with signal 11
39 Correct 1 ms 348 KB Output is correct
40 Runtime error 5 ms 7004 KB Execution killed with signal 11
41 Correct 1 ms 348 KB Output is correct
42 Correct 565 ms 564 KB Output is correct
43 Runtime error 34 ms 50824 KB Execution killed with signal 11
44 Runtime error 2 ms 2396 KB Execution killed with signal 11
45 Runtime error 39 ms 50784 KB Execution killed with signal 11
46 Runtime error 34 ms 50776 KB Execution killed with signal 11
47 Runtime error 39 ms 50768 KB Execution killed with signal 11
48 Runtime error 37 ms 50848 KB Execution killed with signal 11
49 Runtime error 34 ms 50780 KB Execution killed with signal 11
50 Runtime error 35 ms 50772 KB Execution killed with signal 11
51 Runtime error 35 ms 50976 KB Execution killed with signal 11
52 Runtime error 36 ms 50776 KB Execution killed with signal 11
53 Runtime error 40 ms 50772 KB Execution killed with signal 11
54 Runtime error 34 ms 50928 KB Execution killed with signal 11
55 Runtime error 35 ms 50772 KB Execution killed with signal 11
56 Runtime error 34 ms 50776 KB Execution killed with signal 11
57 Runtime error 34 ms 50784 KB Execution killed with signal 11
58 Runtime error 35 ms 51024 KB Execution killed with signal 11
59 Runtime error 35 ms 50832 KB Execution killed with signal 11
60 Runtime error 35 ms 50768 KB Execution killed with signal 11
61 Runtime error 33 ms 50768 KB Execution killed with signal 11
62 Runtime error 40 ms 50872 KB Execution killed with signal 11
63 Runtime error 35 ms 50768 KB Execution killed with signal 11
64 Runtime error 40 ms 50876 KB Execution killed with signal 11
65 Runtime error 33 ms 50780 KB Execution killed with signal 11
66 Runtime error 34 ms 50768 KB Execution killed with signal 11
67 Runtime error 35 ms 50792 KB Execution killed with signal 11
68 Runtime error 33 ms 50880 KB Execution killed with signal 11
69 Runtime error 35 ms 50784 KB Execution killed with signal 11
70 Runtime error 22 ms 32872 KB Execution killed with signal 11
71 Runtime error 33 ms 50784 KB Execution killed with signal 11
72 Runtime error 33 ms 50772 KB Execution killed with signal 11
73 Runtime error 36 ms 50772 KB Execution killed with signal 11
74 Runtime error 42 ms 50772 KB Execution killed with signal 11
75 Runtime error 34 ms 50836 KB Execution killed with signal 11
76 Runtime error 36 ms 50848 KB Execution killed with signal 11
77 Runtime error 34 ms 51036 KB Execution killed with signal 11
78 Runtime error 34 ms 51196 KB Execution killed with signal 11
79 Runtime error 34 ms 50760 KB Execution killed with signal 11
80 Runtime error 36 ms 50872 KB Execution killed with signal 11
81 Runtime error 34 ms 50784 KB Execution killed with signal 11
82 Runtime error 33 ms 50780 KB Execution killed with signal 11
83 Runtime error 41 ms 50768 KB Execution killed with signal 11
84 Runtime error 34 ms 50772 KB Execution killed with signal 11
85 Runtime error 36 ms 50820 KB Execution killed with signal 11
86 Runtime error 39 ms 51028 KB Execution killed with signal 11
87 Runtime error 34 ms 50768 KB Execution killed with signal 11
88 Runtime error 39 ms 50784 KB Execution killed with signal 11
89 Runtime error 37 ms 50892 KB Execution killed with signal 11
90 Runtime error 21 ms 32860 KB Execution killed with signal 11
91 Runtime error 33 ms 50772 KB Execution killed with signal 11
92 Runtime error 33 ms 50780 KB Execution killed with signal 11
93 Runtime error 38 ms 50776 KB Execution killed with signal 11
94 Runtime error 36 ms 50756 KB Execution killed with signal 11
95 Runtime error 34 ms 50780 KB Execution killed with signal 11
96 Runtime error 34 ms 50968 KB Execution killed with signal 11
97 Runtime error 36 ms 50780 KB Execution killed with signal 11
98 Runtime error 35 ms 50920 KB Execution killed with signal 11
99 Runtime error 34 ms 50768 KB Execution killed with signal 11
100 Runtime error 39 ms 51132 KB Execution killed with signal 11