Submission #2006602


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;
  ll 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;
      }
    }
  }
  
  ll 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];
    }
  }


  
  ll ans =0;
  REP(i,h){
    REP(j,w){
      for(int k=i;k<h;k++){
        for(int l=j;l<w;l++){
          ll chokoSum;
          if(i==0&&j==0){
            chokoSum = hs[k][l];
          }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 1252 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:58:42: error: no matching function for call to ‘max(ll&, int)’
             ans = max(ans,(k-i+1)*(l-j+1));
                                          ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
./Main.cpp:58:42: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’...