Submission #752884

#TimeUsernameProblemLanguageResultExecution timeMemory
752884bgnbvnbvThe Kingdom of JOIOI (JOI17_joioi)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=4e6+10; const ll inf=1e18; const ll mod=1e9+7; ll n,m; ll ans=inf; ll a[2006][2006],b[2006][2006],mx=-inf,mn=inf; bool check(ll mid) { ll mxr=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(b[i][j]<mx-mid) mxr=max(mxr,j); } for(int j=1;j<=mxr;j++) { if(b[i][j]-mn>mid) return false; } } return true; } ll solve1() { ll low=0,high=mx-mn-1; while(low<=high) { ll mid=low+high>>1; if(check(mid)) high=mid-1; else low=mid+1; } return low; } void rot() { for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { b[m-j+1][i]=a[i][j]; } } swap(m,n); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) a[i][j]=b[i][j]; } } void solve() { cin >> n >> m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) cin >> a[i][j],b[i][j]=a[i][j],mx=max(mx,a[i][j]),mn=min(mn,a[i][j]); } ans=min(ans,solve1()); rot(); ans=min(ans,solve1()); rot(); ans=min(ans,solve1()); rot(); ans=min(ans,solve1()); cout << ans; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }

Compilation message (stderr)

joioi.cpp: In function 'bool check(ll)':
joioi.cpp:24:45: error: no matching function for call to 'max(ll&, int&)'
   24 |             if(b[i][j]<mx-mid) mxr=max(mxr,j);
      |                                             ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from joioi.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:
joioi.cpp:24:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |             if(b[i][j]<mx-mid) mxr=max(mxr,j);
      |                                             ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from joioi.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:
joioi.cpp:24:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |             if(b[i][j]<mx-mid) mxr=max(mxr,j);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joioi.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:
joioi.cpp:24:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |             if(b[i][j]<mx-mid) mxr=max(mxr,j);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joioi.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:
joioi.cpp:24:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |             if(b[i][j]<mx-mid) mxr=max(mxr,j);
      |                                             ^
joioi.cpp: In function 'll solve1()':
joioi.cpp:38:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |         ll mid=low+high>>1;
      |                ~~~^~~~~