답안 #915529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915529 2024-01-24T06:28:54 Z vjudge1 Bomb (IZhO17_bomb) C++17
29 / 100
1000 ms 51296 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();
	}
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 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 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 26 ms 516 KB Output is correct
18 Correct 36 ms 512 KB Output is correct
19 Correct 75 ms 348 KB Output is correct
20 Correct 82 ms 348 KB Output is correct
21 Correct 32 ms 344 KB Output is correct
22 Correct 71 ms 344 KB Output is correct
23 Correct 130 ms 348 KB Output is correct
24 Correct 52 ms 344 KB Output is correct
25 Correct 182 ms 544 KB Output is correct
26 Execution timed out 1042 ms 348 KB Time limit exceeded
27 Runtime error 2 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 2136 KB Execution killed with signal 11
31 Runtime error 3 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 2 ms 1372 KB Execution killed with signal 11
35 Runtime error 3 ms 2140 KB Execution killed with signal 11
36 Runtime error 2 ms 2140 KB Execution killed with signal 11
37 Correct 1 ms 348 KB Output is correct
38 Runtime error 37 ms 51028 KB Execution killed with signal 11
39 Correct 1 ms 348 KB Output is correct
40 Runtime error 6 ms 6824 KB Execution killed with signal 11
41 Correct 1 ms 348 KB Output is correct
42 Correct 491 ms 560 KB Output is correct
43 Runtime error 36 ms 51024 KB Execution killed with signal 11
44 Runtime error 3 ms 2136 KB Execution killed with signal 11
45 Runtime error 36 ms 51044 KB Execution killed with signal 11
46 Runtime error 41 ms 51028 KB Execution killed with signal 11
47 Runtime error 37 ms 51036 KB Execution killed with signal 11
48 Runtime error 38 ms 51024 KB Execution killed with signal 11
49 Runtime error 40 ms 51052 KB Execution killed with signal 11
50 Runtime error 36 ms 51028 KB Execution killed with signal 11
51 Runtime error 36 ms 51024 KB Execution killed with signal 11
52 Runtime error 37 ms 51032 KB Execution killed with signal 11
53 Runtime error 38 ms 51024 KB Execution killed with signal 11
54 Runtime error 36 ms 51036 KB Execution killed with signal 11
55 Runtime error 38 ms 51028 KB Execution killed with signal 11
56 Runtime error 42 ms 51296 KB Execution killed with signal 11
57 Runtime error 37 ms 51048 KB Execution killed with signal 11
58 Runtime error 36 ms 51040 KB Execution killed with signal 11
59 Runtime error 40 ms 51040 KB Execution killed with signal 11
60 Runtime error 37 ms 50972 KB Execution killed with signal 11
61 Runtime error 40 ms 51020 KB Execution killed with signal 11
62 Runtime error 36 ms 51036 KB Execution killed with signal 11
63 Runtime error 37 ms 50964 KB Execution killed with signal 11
64 Runtime error 38 ms 51124 KB Execution killed with signal 11
65 Runtime error 37 ms 51104 KB Execution killed with signal 11
66 Runtime error 35 ms 51036 KB Execution killed with signal 11
67 Runtime error 36 ms 51036 KB Execution killed with signal 11
68 Runtime error 40 ms 51028 KB Execution killed with signal 11
69 Runtime error 37 ms 51092 KB Execution killed with signal 11
70 Runtime error 24 ms 33024 KB Execution killed with signal 11
71 Runtime error 37 ms 51064 KB Execution killed with signal 11
72 Runtime error 37 ms 51024 KB Execution killed with signal 11
73 Runtime error 38 ms 50956 KB Execution killed with signal 11
74 Runtime error 36 ms 51036 KB Execution killed with signal 11
75 Runtime error 37 ms 51068 KB Execution killed with signal 11
76 Runtime error 37 ms 51028 KB Execution killed with signal 11
77 Runtime error 37 ms 51028 KB Execution killed with signal 11
78 Runtime error 37 ms 51036 KB Execution killed with signal 11
79 Runtime error 37 ms 51028 KB Execution killed with signal 11
80 Runtime error 36 ms 51028 KB Execution killed with signal 11
81 Runtime error 36 ms 51036 KB Execution killed with signal 11
82 Runtime error 37 ms 50996 KB Execution killed with signal 11
83 Runtime error 36 ms 51024 KB Execution killed with signal 11
84 Runtime error 40 ms 51032 KB Execution killed with signal 11
85 Runtime error 38 ms 50936 KB Execution killed with signal 11
86 Runtime error 36 ms 51024 KB Execution killed with signal 11
87 Runtime error 35 ms 51032 KB Execution killed with signal 11
88 Runtime error 37 ms 51024 KB Execution killed with signal 11
89 Runtime error 36 ms 51020 KB Execution killed with signal 11
90 Runtime error 23 ms 33108 KB Execution killed with signal 11
91 Runtime error 36 ms 51028 KB Execution killed with signal 11
92 Runtime error 42 ms 51280 KB Execution killed with signal 11
93 Runtime error 38 ms 50988 KB Execution killed with signal 11
94 Runtime error 36 ms 51040 KB Execution killed with signal 11
95 Runtime error 42 ms 51060 KB Execution killed with signal 11
96 Runtime error 38 ms 51108 KB Execution killed with signal 11
97 Runtime error 36 ms 51036 KB Execution killed with signal 11
98 Runtime error 40 ms 51028 KB Execution killed with signal 11
99 Runtime error 36 ms 51036 KB Execution killed with signal 11
100 Runtime error 37 ms 51116 KB Execution killed with signal 11