Submission #1234597

#TimeUsernameProblemLanguageResultExecution timeMemory
1234597Ghulam_JunaidCatfish Farm (IOI22_fish)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; typedef long long ll; ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { ll mat[n + 5][n + 5] = {}, pref[n + 5][n + 5] = {}; for (int i = 0; i < m; i ++) mat[x[i] + 1][y[i] + 1] = w[i]; for (int i = 1; i <= n; i ++) for (int j = 1; j <= n; j ++) pref[i][j] = pref[i][j - 1] + mat[i][j]; ll dp[n + 1][n + 1][2] = {}; for (int k = 1; k <= n; k ++) dp[1][k][0] = pref[2][k]; for (int i = 2; i <= n; i ++){ for (int k = 0; k <= n; k ++){ for (int pk = 0; pk <= n; pk ++){ if (k >= pk) dp[i][k][0] = dp[i - 1][pk][0] - pref[i][pk] + pref[i - 1][k] - pref[i - 1][pk] + pref[i + 1][k]; else dp[i][k][1] = max(dp[i - 1][pk][0], dp[i - 1][pk][1]) - pref[i][k] + pref[i + 1][k]; dp[i][k][0] = max(dp[i][k][0], max(dp[i - 2][pk][0], dp[i - 2][pk][1]) - pref[i - 1][pk] + pref[i - 1][max(pk, k)] + pref[i + 1][k]); } } } ll ans = 0; for (int k = 0; k <= n; k ++) ans = max(ans, dp[n][k]); return ans; }

Compilation message (stderr)

fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:32:18: error: no matching function for call to 'max(ll&, ll [2])'
   32 |         ans = max(ans, dp[n][k]);
      |               ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from fish.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
fish.cpp:32:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll [2]' {aka 'long long int [2]'})
   32 |         ans = max(ans, dp[n][k]);
      |               ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from fish.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
fish.cpp:32:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll [2]' {aka 'long long int [2]'})
   32 |         ans = max(ans, dp[n][k]);
      |               ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from fish.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
fish.cpp:32:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         ans = max(ans, dp[n][k]);
      |               ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from fish.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
fish.cpp:32:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         ans = max(ans, dp[n][k]);
      |               ~~~^~~~~~~~~~~~~~~