답안 #915543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915543 2024-01-24T06:52:35 Z vjudge1 Bomb (IZhO17_bomb) C++17
컴파일 오류
0 ms 0 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 <iostream>
#define pb push_back
using namespace std;

int pp[501][501];
int u[501][501];

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();
	}
}


Compilation message

bomb.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("unroll-loops")
      | 
bomb.cpp: In function 'void solve()':
bomb.cpp:17:9: error: 'str' was not declared in this scope; did you mean 'std'?
   17 |         str s;
      |         ^~~
      |         std
bomb.cpp:18:14: error: 's' was not declared in this scope
   18 |         cin>>s;
      |              ^
bomb.cpp:19:9: error: 'vector' was not declared in this scope
   19 |         vector<int >v;
      |         ^~~~~~
bomb.cpp:7:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    6 | #include <iostream>
  +++ |+#include <vector>
    7 | #define pb push_back
bomb.cpp:19:16: error: expected primary-expression before 'int'
   19 |         vector<int >v;
      |                ^~~
bomb.cpp:25:21: error: 'v' was not declared in this scope
   25 |                     v.pb(k);
      |                     ^
bomb.cpp:31:13: error: 'v' was not declared in this scope
   31 |             v.pb(k);
      |             ^
bomb.cpp:34:12: error: 'v' was not declared in this scope
   34 |         if(v.size()==0){
      |            ^
bomb.cpp:40:32: error: 'v' was not declared in this scope
   40 |             for(int j=0;j<(int)v.size();j++){
      |                                ^
bomb.cpp:54:9: error: 'vector' was not declared in this scope
   54 |         vector<int >v;
      |         ^~~~~~
bomb.cpp:54:9: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
bomb.cpp:54:16: error: expected primary-expression before 'int'
   54 |         vector<int >v;
      |                ^~~
bomb.cpp:61:21: error: 'v' was not declared in this scope
   61 |                     v.pb(k);
      |                     ^
bomb.cpp:67:13: error: 'v' was not declared in this scope
   67 |             v.pb(k);
      |             ^
bomb.cpp:70:12: error: 'v' was not declared in this scope
   70 |         if(v.size()==0){
      |            ^
bomb.cpp:76:32: error: 'v' was not declared in this scope
   76 |             for(int j=0;j<(int)v.size();j++){
      |                                ^
bomb.cpp:89:9: error: 'str' was not declared in this scope; did you mean 'std'?
   89 |         str s[n+3];
      |         ^~~
      |         std
bomb.cpp:93:18: error: 's' was not declared in this scope
   93 |             cin>>s[i];
      |                  ^