Submission #204505

#TimeUsernameProblemLanguageResultExecution timeMemory
204505arnold518Abduction 2 (JOI17_abduction2)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e4; int N, M, Q; int A[MAXN+10], B[MAXN+10]; int LA[MAXN+10][20], RA[MAXN+10][20]; int LB[MAXN+10][20], RB[MAXN+10][20]; map<pair<pii, int>, ll> memo; ll solve(int y, int x, int d) { if(memo.find({{y, x}, d})!=memo.end()) return memo[{{y, x}, d}]; int i, j; ll ret=0; int l, r, k; if(d==0) { l=y-1; r=y+1; k=B[x]; for(i=16; i>=0; i--) if(LA[l][i]<=k) l=max(0, l-(1<<i)); for(i=16; i>=0; i--) if(RA[r][i]<=k) r=min(N+1, r+(1<<i)); if(l==0) ret=max(ret, y-1); else ret=max(ret, y-l+solve(l, x, 1)); if(r==N+1) ret=max(ret, N-y); else ret=max(ret, r-y+solve(r, x, 1)); } else { l=x-1; r=x+1; k=A[y]; for(i=16; i>=0; i--) if(LB[l][i]<=k) l=max(0, l-(1<<i)); for(i=16; i>=0; i--) if(RB[r][i]<=k) r=min(M+1, r+(1<<i)); if(l==0) ret=max(ret, x-1); else ret=max(ret, x-l+solve(y, l, 0)); if(r==M+1) ret=max(ret, M-x); else ret=max(ret, r-x+solve(y, r, 0)); } memo[{{y, x}, d}]=ret; return ret; } int main() { int i, j; scanf("%d%d%d", &N, &M, &Q); for(i=1; i<=N; i++) scanf("%d", &A[i]); for(i=1; i<=M; i++) scanf("%d", &B[i]); for(i=1; i<=N; i++) LA[i][0]=RA[i][0]=A[i]; for(i=1; i<=16; i++) for(j=1; j<=N; j++) LA[j][i]=max(LA[j][i-1], LA[max(0, j-(1<<(i-1)))][i-1]); for(i=1; i<=16; i++) for(j=1; j<=N; j++) RA[j][i]=max(RA[j][i-1], RA[min(N+1, j+(1<<(i-1)))][i-1]); for(i=1; i<=M; i++) LB[i][0]=RB[i][0]=B[i]; for(i=1; i<=16; i++) for(j=1; j<=M; j++) LB[j][i]=max(LB[j][i-1], LB[max(0, j-(1<<(i-1)))][i-1]); for(i=1; i<=16; i++) for(j=1; j<=M; j++) RB[j][i]=max(RB[j][i-1], RB[min(M+1, j+(1<<(i-1)))][i-1]); while(Q--) { int y, x; scanf("%d%d", &y, &x); printf("%lld\n", max(solve(y, x, 0), solve(y, x, 1))); } }

Compilation message (stderr)

abduction2.cpp: In function 'll solve(int, int, int)':
abduction2.cpp:31:28: error: no matching function for call to 'max(ll&, int)'
   if(l==0) ret=max(ret, y-1);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
abduction2.cpp:31:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(l==0) ret=max(ret, y-1);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
abduction2.cpp:31:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(l==0) ret=max(ret, y-1);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
abduction2.cpp:31:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(l==0) ret=max(ret, y-1);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
abduction2.cpp:31:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(l==0) ret=max(ret, y-1);
                            ^
abduction2.cpp:34:30: error: no matching function for call to 'max(ll&, int)'
   if(r==N+1) ret=max(ret, N-y);
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
abduction2.cpp:34:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(r==N+1) ret=max(ret, N-y);
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
abduction2.cpp:34:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(r==N+1) ret=max(ret, N-y);
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
abduction2.cpp:34:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(r==N+1) ret=max(ret, N-y);
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
abduction2.cpp:34:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(r==N+1) ret=max(ret, N-y);
                              ^
abduction2.cpp:43:28: error: no matching function for call to 'max(ll&, int)'
   if(l==0) ret=max(ret, x-1);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
abduction2.cpp:43:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(l==0) ret=max(ret, x-1);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
abduction2.cpp:43:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(l==0) ret=max(ret, x-1);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
abduction2.cpp:43:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(l==0) ret=max(ret, x-1);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
abduction2.cpp:43:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(l==0) ret=max(ret, x-1);
                            ^
abduction2.cpp:46:30: error: no matching function for call to 'max(ll&, int)'
   if(r==M+1) ret=max(ret, M-x);
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
abduction2.cpp:46:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(r==M+1) ret=max(ret, M-x);
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
abduction2.cpp:46:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   if(r==M+1) ret=max(ret, M-x);
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
abduction2.cpp:46:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(r==M+1) ret=max(ret, M-x);
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from abduction2.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
abduction2.cpp:46:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   if(r==M+1) ret=max(ret, M-x);
                              ^
abduction2.cpp:21:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
abduction2.cpp: In function 'int main()':
abduction2.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &N, &M, &Q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
abduction2.cpp:58:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%d", &A[i]);
                      ~~~~~^~~~~~~~~~~~~
abduction2.cpp:59:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=M; i++) scanf("%d", &B[i]);
                      ~~~~~^~~~~~~~~~~~~
abduction2.cpp:72:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &y, &x);
   ~~~~~^~~~~~~~~~~~~~~~