제출 #1110808

#제출 시각아이디문제언어결과실행 시간메모리
1110808epicci23Rectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;


long long count_rectangles(vector<vector<int>> ar){
  int n=sz(ar),m=sz(ar[0]);
  int64_t ans=0,a[n+5][m+5];
  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=ar[i-1][j-1];
  
  for(int i=2;i<n;i++){
    for(int j=2;j<m;j++){
      if(a[i][j]>=a[i-1][j] || a[i][j]>=a[i][j-1]) continue;
      
      for(int alt=i;alt<n;alt++){
       vector<int64_t> mr(n+5,0);

       for(int z=j;z<m;z++){
         int cl=0;
         bool ok=1;
         for(int k=i;k<=alt;k++){
          mr[k]=max(mr[k],a[k][z]);
          cl=max(cl,a[k][z]);
          if(min(a[k][j-1],a[k][z+1])<=mr[k]) ok=0;
         }
         if(min(a[i-1][z],a[alt+1][z])<=cl) break;
         ans+=ok;
       }

      }


    }
  }

  return ans;
}



/*void _(){
  int n,m;
  cin >> n >> m;
  int ans=0,a[n+5][m+5];
  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin >> a[i][j];
  
  for(int i=2;i<n;i++){
  	for(int j=2;j<m;j++){
  	  if(a[i][j]>=a[i-1][j] || a[i][j]>=a[i][j-1]) continue;
  	  
      for(int alt=i;alt<n;alt++){
       vector<int> mr(n+5,0);

       for(int z=j;z<m;z++){
         int cl=0;
         bool ok=1;
         for(int k=i;k<=alt;k++){
          mr[k]=max(mr[k],a[k][z]);
          cl=max(cl,a[k][z]);
          if(min(a[k][j-1],a[k][z+1])<=mr[k]) ok=0;
         }
         if(min(a[i-1][z],a[alt+1][z])<=cl) break;
         ans+=ok;
       }

      }


  	}
  }

  cout << ans << '\n';
}

int32_t main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tc=1;//cin >> tc;
  while(tc--) _();
  return 0;
}*/

컴파일 시 표준 에러 (stderr) 메시지

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:25:28: error: no matching function for call to 'max(int&, int64_t&)'
   25 |           cl=max(cl,a[k][z]);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
rect.cpp:25:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   25 |           cl=max(cl,a[k][z]);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
rect.cpp:25:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   25 |           cl=max(cl,a[k][z]);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
rect.cpp:25:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |           cl=max(cl,a[k][z]);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
rect.cpp:25:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |           cl=max(cl,a[k][z]);
      |                            ^