답안 #915537

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915537 2024-01-24T06:35:41 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 <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define int int_16
#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[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:9:13: error: 'int_16' does not name a type
    9 | #define int int_16
      |             ^~~~~~
bomb.cpp:27:1: note: in expansion of macro 'int'
   27 | int pp[501][501];
      | ^~~
bomb.cpp:9:13: error: 'int_16' does not name a type
    9 | #define int int_16
      |             ^~~~~~
bomb.cpp:28:1: note: in expansion of macro 'int'
   28 | int u[501][501];
      | ^~~
bomb.cpp: In function 'void solve()':
bomb.cpp:9:13: error: 'int_16' was not declared in this scope
    9 | #define int int_16
      |             ^~~~~~
bomb.cpp:31:5: note: in expansion of macro 'int'
   31 |     int n,m;
      |     ^~~
bomb.cpp:32:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   32 |     cin>>n>>m;
      |          ^
      |          yn
bomb.cpp:32:13: error: 'm' was not declared in this scope; did you mean 'tm'?
   32 |     cin>>n>>m;
      |             ^
      |             tm
bomb.cpp:36:20: error: template argument 2 is invalid
   36 |         vector<int >v;
      |                    ^
bomb.cpp:37:13: error: expected ';' before 'k'
   37 |         int k=0;
      |             ^
bomb.cpp:38:17: error: expected ';' before 'i'
   38 |         for(int i=0;i<m;i++){
      |                 ^
bomb.cpp:38:21: error: 'i' was not declared in this scope
   38 |         for(int i=0;i<m;i++){
      |                     ^
bomb.cpp:39:26: error: 'k' was not declared in this scope
   39 |             if(s[i]=='1')k++;
      |                          ^
bomb.cpp:41:20: error: 'k' was not declared in this scope
   41 |                 if(k>0){
      |                    ^
bomb.cpp:10:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   10 | #define pb push_back
      |            ^~~~~~~~~
bomb.cpp:42:23: note: in expansion of macro 'pb'
   42 |                     v.pb(k);
      |                       ^~
bomb.cpp:47:12: error: 'k' was not declared in this scope
   47 |         if(k>0){
      |            ^
bomb.cpp:10:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   10 | #define pb push_back
      |            ^~~~~~~~~
bomb.cpp:48:15: note: in expansion of macro 'pb'
   48 |             v.pb(k);
      |               ^~
bomb.cpp:50:13: error: expected ';' before 'ans'
   50 |         int ans=1;
      |             ^~~
bomb.cpp:51:14: error: request for member 'size' in 'v', which is of non-class type 'int'
   51 |         if(v.size()==0){
      |              ^~~~
bomb.cpp:55:17: error: expected ';' before 'i'
   55 |         for(int i=2;i<=m;i++){
      |                 ^
bomb.cpp:55:21: error: 'i' was not declared in this scope
   55 |         for(int i=2;i<=m;i++){
      |                     ^
bomb.cpp:56:13: error: 'k' was not declared in this scope
   56 |             k=1;
      |             ^
bomb.cpp:57:21: error: expected ';' before 'j'
   57 |             for(int j=0;j<(int)v.size();j++){
      |                     ^
bomb.cpp:57:25: error: 'j' was not declared in this scope
   57 |             for(int j=0;j<(int)v.size();j++){
      |                         ^
bomb.cpp:57:32: error: expected ';' before 'v'
   57 |             for(int j=0;j<(int)v.size();j++){
      |                                ^
      |                                ;
bomb.cpp:57:34: error: request for member 'size' in 'v', which is of non-class type 'int'
   57 |             for(int j=0;j<(int)v.size();j++){
      |                                  ^~~~
bomb.cpp:57:40: error: expected ')' before ';' token
   57 |             for(int j=0;j<(int)v.size();j++){
      |                ~                       ^
      |                                        )
bomb.cpp:57:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   57 |             for(int j=0;j<(int)v.size();j++){
      |             ^~~
bomb.cpp:57:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   57 |             for(int j=0;j<(int)v.size();j++){
      |                                         ^
bomb.cpp:57:41: error: 'j' was not declared in this scope
bomb.cpp:64:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |                 ans=i;
      |                 ^~~
      |                 abs
bomb.cpp:67:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   67 |         cout<<ans;
      |               ^~~
      |               abs
bomb.cpp:71:20: error: template argument 2 is invalid
   71 |         vector<int >v;
      |                    ^
bomb.cpp:72:13: error: expected ';' before 'k'
   72 |         int k=0;
      |             ^
bomb.cpp:73:17: error: expected ';' before 'i'
   73 |         for(int i=0;i<n;i++){
      |                 ^
bomb.cpp:73:21: error: 'i' was not declared in this scope
   73 |         for(int i=0;i<n;i++){
      |                     ^
bomb.cpp:75:23: error: 'k' was not declared in this scope
   75 |             if(s=='1')k++;
      |                       ^
bomb.cpp:77:20: error: 'k' was not declared in this scope
   77 |                 if(k>0){
      |                    ^
bomb.cpp:10:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   10 | #define pb push_back
      |            ^~~~~~~~~
bomb.cpp:78:23: note: in expansion of macro 'pb'
   78 |                     v.pb(k);
      |                       ^~
bomb.cpp:83:12: error: 'k' was not declared in this scope
   83 |         if(k>0){
      |            ^
bomb.cpp:10:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   10 | #define pb push_back
      |            ^~~~~~~~~
bomb.cpp:84:15: note: in expansion of macro 'pb'
   84 |             v.pb(k);
      |               ^~
bomb.cpp:86:13: error: expected ';' before 'ans'
   86 |         int ans=1;
      |             ^~~
bomb.cpp:87:14: error: request for member 'size' in 'v', which is of non-class type 'int'
   87 |         if(v.size()==0){
      |              ^~~~
bomb.cpp:91:17: error: expected ';' before 'i'
   91 |         for(int i=2;i<=n;i++){
      |                 ^
bomb.cpp:91:21: error: 'i' was not declared in this scope
   91 |         for(int i=2;i<=n;i++){
      |                     ^
bomb.cpp:92:13: error: 'k' was not declared in this scope
   92 |             k=1;
      |             ^
bomb.cpp:93:21: error: expected ';' before 'j'
   93 |             for(int j=0;j<(int)v.size();j++){
      |                     ^
bomb.cpp:93:25: error: 'j' was not declared in this scope
   93 |             for(int j=0;j<(int)v.size();j++){
      |                         ^
bomb.cpp:93:32: error: expected ';' before 'v'
   93 |             for(int j=0;j<(int)v.size();j++){
      |                                ^
      |                                ;
bomb.cpp:93:34: error: request for member 'size' in 'v', which is of non-class type 'int'
   93 |             for(int j=0;j<(int)v.size();j++){
      |                                  ^~~~
bomb.cpp:93:40: error: expected ')' before ';' token
   93 |             for(int j=0;j<(int)v.size();j++){
      |                ~                       ^
      |                                        )
bomb.cpp:93:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   93 |             for(int j=0;j<(int)v.size();j++){
      |             ^~~
bomb.cpp:93:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   93 |             for(int j=0;j<(int)v.size();j++){
      |                                         ^
bomb.cpp:93:41: error: 'j' was not declared in this scope
bomb.cpp:100:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  100 |                 ans=i;
      |                 ^~~
      |                 abs
bomb.cpp:103:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
  103 |         cout<<ans;
      |               ^~~
      |               abs
bomb.cpp:107:13: error: expected ';' before 'a'
  107 |         int a[n+3][m+3];
      |             ^
bomb.cpp:108:13: error: expected ';' before 'o'
  108 |         int o=0;
      |             ^
bomb.cpp:109:17: error: expected ';' before 'i'
  109 |         for(int i=1;i<=n;i++){
      |                 ^
bomb.cpp:109:21: error: 'i' was not declared in this scope; did you mean 'vi'?
  109 |         for(int i=1;i<=n;i++){
      |                     ^
      |                     vi
bomb.cpp:110:18: error: 's' was not declared in this scope; did you mean 'ss'?
  110 |             cin>>s[i];
      |                  ^
      |                  ss
bomb.cpp:111:21: error: expected ';' before 'j'
  111 |             for(int j=0;j<m;j++){
      |                     ^
bomb.cpp:111:25: error: 'j' was not declared in this scope; did you mean 'jn'?
  111 |             for(int j=0;j<m;j++){
      |                         ^
      |                         jn
bomb.cpp:112:17: error: 'a' was not declared in this scope
  112 |                 a[i][j+1]=s[i][j]-'0';
      |                 ^
bomb.cpp:113:17: error: 'o' was not declared in this scope; did you mean 'no'?
  113 |                 o+=(a[i][j]==1);
      |                 ^
      |                 no
bomb.cpp:114:17: error: 'pp' was not declared in this scope; did you mean 'mp'?
  114 |                 pp[i][j+1]=a[i][j+1]+pp[i][j]+pp[i-1][j+1]-pp[i-1][j];
      |                 ^~
      |                 mp
bomb.cpp:117:12: error: 'o' was not declared in this scope; did you mean 'no'?
  117 |         if(o==0){
      |            ^
      |            no
bomb.cpp:121:13: error: expected ';' before 'ans'
  121 |         int ans=0;
      |             ^~~
bomb.cpp:122:17: error: expected ';' before 'i'
  122 |         for(int i=1;i<=n;i++){
      |                 ^
bomb.cpp:122:21: error: 'i' was not declared in this scope; did you mean 'vi'?
  122 |         for(int i=1;i<=n;i++){
      |                     ^
      |                     vi
bomb.cpp:123:21: error: expected ';' before 'j'
  123 |             for(int j=1;j<=m;j++){
      |                     ^
bomb.cpp:123:25: error: 'j' was not declared in this scope; did you mean 'jn'?
  123 |             for(int j=1;j<=m;j++){
      |                         ^
      |                         jn
bomb.cpp:124:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
  124 |                 if(i*j<=ans){
      |                         ^~~
      |                         abs
bomb.cpp:127:25: error: expected ';' before 'i1'
  127 |                 for(int i1=1;i1<=n;i1++){
      |                         ^~
bomb.cpp:127:30: error: 'i1' was not declared in this scope; did you mean 'y1'?
  127 |                 for(int i1=1;i1<=n;i1++){
      |                              ^~
      |                              y1
bomb.cpp:128:29: error: expected ';' before 'j1'
  128 |                     for(int j1=1;j1<=m;j1++){
      |                             ^~
bomb.cpp:128:40: warning: ISO C++ forbids incrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
  128 |                     for(int j1=1;j1<=m;j1++){
      |                                        ^~
bomb.cpp:128:40: error: lvalue required as increment operand
bomb.cpp:129:25: error: 'u' was not declared in this scope
  129 |                         u[i1][j1]=0;
      |                         ^
bomb.cpp:132:25: error: expected ';' before 'i1'
  132 |                 for(int i1=1;i1<=n;i1++){
      |                         ^~
bomb.cpp:132:30: error: 'i1' was not declared in this scope; did you mean 'y1'?
  132 |                 for(int i1=1;i1<=n;i1++){
      |                              ^~
      |                              y1
bomb.cpp:133:29: error: expected ';' before 'j1'
  133 |                     for(int j1=1;j1<=m;j1++){
      |                             ^~
bomb.cpp:133:40: warning: ISO C++ forbids incrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
  133 |                     for(int j1=1;j1<=m;j1++){
      |                                        ^~
bomb.cpp:133:40: error: lvalue required as increment operand
bomb.cpp:135:28: error: 'pp' was not declared in this scope; did you mean 'mp'?
  135 |                         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){
      |                            ^~
      |                            mp
bomb.cpp:135:58: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  135 |                         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){
      |                                                        ~~^~
bomb.cpp:135:75: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  135 |                         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){
      |                                                                         ~~^~
bomb.cpp:136:37: error: expected ';' before 'i2'
  136 |                             for(int i2=i1;i2<=i1+i-1;i2++){
      |                                     ^~
bomb.cpp:136:43: error: 'i2' was not declared in this scope
  136 |                             for(int i2=i1;i2<=i1+i-1;i2++){
      |                                           ^~
bomb.cpp:137:41: error: expected ';' before 'j2'
  137 |                                 for(int j2=j1;j2<=j1+j-1;j2++){
      |                                         ^~
bomb.cpp:137:47: error: 'j2' was not declared in this scope; did you mean 'jn'?
  137 |                                 for(int j2=j1;j2<=j1+j-1;j2++){
      |                                               ^~
      |                                               jn
bomb.cpp:138:37: error: 'u' was not declared in this scope
  138 |                                     u[i2][j2]=1;
      |                                     ^
bomb.cpp:144:21: error: expected ';' before 'k'
  144 |                 int k=1;
      |                     ^
bomb.cpp:145:25: error: expected ';' before 'i1'
  145 |                 for(int i1=1;i1<=n;i1++){
      |                         ^~
bomb.cpp:145:30: error: 'i1' was not declared in this scope; did you mean 'y1'?
  145 |                 for(int i1=1;i1<=n;i1++){
      |                              ^~
      |                              y1
bomb.cpp:146:29: error: expected ';' before 'j1'
  146 |                     for(int j1=1;j1<=m;j1++){
      |                             ^~
bomb.cpp:146:40: warning: ISO C++ forbids incrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
  146 |                     for(int j1=1;j1<=m;j1++){
      |                                        ^~
bomb.cpp:146:40: error: lvalue required as increment operand
bomb.cpp:147:28: error: 'u' was not declared in this scope
  147 |                         if(u[i1][j1]!=a[i1][j1]){
      |                            ^
bomb.cpp:147:39: error: 'a' was not declared in this scope
  147 |                         if(u[i1][j1]!=a[i1][j1]){
      |                                       ^
bomb.cpp:148:29: error: 'k' was not declared in this scope
  148 |                             k=0;
      |                             ^
bomb.cpp:153:20: error: 'k' was not declared in this scope
  153 |                 if(k==1){
      |                    ^
bomb.cpp:161:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
  161 |                     ans=max(ans,i*j);
      |                     ^~~
      |                     abs
bomb.cpp:165:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
  165 |         cout<<ans;
      |               ^~~
      |               abs
bomb.cpp: In function 'int main()':
bomb.cpp:9:13: error: 'int_16' was not declared in this scope
    9 | #define int int_16
      |             ^~~~~~
bomb.cpp:175:5: note: in expansion of macro 'int'
  175 |     int tests=1;
      |     ^~~
bomb.cpp:177:13: error: expected ';' before 'i'
  177 |     for(int i=1;i<=tests;i++){
      |             ^
bomb.cpp:177:17: error: 'i' was not declared in this scope; did you mean 'vi'?
  177 |     for(int i=1;i<=tests;i++){
      |                 ^
      |                 vi
bomb.cpp:177:20