Submission #2006562
Source Code Expand
#include <bits/stdc++.h> #include <vector> #define REP(i,n) for(int i=0;i<n;i++) using namespace std; typedef long long ll; int h,w; int main(){ cin>>h>>w; int c[h][w]; REP(i,h){ REP(j,w){ int k; cin>>k; if((i+j)%2==0){ c[i][j] = k; }else{ c[i][j] = -k; } } } int hs[h][w]; hs[0][0] = c[0][0]; for(int i=1;i<h;i++){ hs[i][0] = hs[i-1][0] + c[i][0]; } for(int i=1;i<w;i++){ hs[0][i] = hs[0][i-1] + c[0][i]; } for(int i=1;i<h;i++){ for(int j=1;j<w;j++){ hs[i][j] = hs[i-1][j] + hs[i][j-1] - hs[i-1][j-1] + c[i][j]; } } REP(i,h){ REP(i,w){ cout<< int ans =0; REP(i,h){ REP(j,w){ for(int k=i;k<h;k++){ for(int l=j;l<w;l++){ int chokoSum; if(i==0&&j==0){ chokoSum = hs[i][j]; }else if(i==0){ chokoSum = hs[k][l] - hs[i][j-1]; }else if(j==0){ chokoSum = hs[k][l] - hs[i-1][j]; }else{ chokoSum = hs[k][l] - hs[k][j-1] - hs[i-1][l] + hs[i-1][j-1]; } if(chokoSum == 0){ ans = max(ans,(k-i+1)*(l-j+1)); } } } } } cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | B - チョコレート |
User | pue |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1296 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:44:3: error: expected primary-expression before ‘int’ int ans =0; ^ ./Main.cpp:60:13: error: ‘ans’ was not declared in this scope ans = max(ans,(k-i+1)*(l-j+1)); ^ ./Main.cpp:66:9: error: ‘ans’ was not declared in this scope cout<<ans<<endl; ^ ./Main.cpp:67:1: error: expected ‘}’ at end of input } ^ ./Main.cpp:67:1: error: expected ‘}’ at end of input