# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
993507 | 2024-06-05T21:13:47 Z | cpdreamer | Catfish Farm (IOI22_fish) | C++17 | Compilation error |
0 ms | 0 KB |
#include "fish.h" #include <bits/stdc++.h> using namespace std; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) { vector<vector<long long>> grid(N+1, vector<long long>(N + 1)); for (int i = 0; i <= N; i++) grid[i].assign(N + 1, 0); long long dp[N][N + 1][N + 1]; long long vp[N][N + 1][N + 1]; for (int i = 0; i < M; i++) { grid[X[i] ][Y[i]+1] += W[i]; } for (int i = 0; i <=N; i++) { for (int j = 1; j <= N; j++) { grid[i][j] += grid[i][j - 1]; } } for (int i = 0; i <=N; i++) { for (int j = 0; j <= N; j++) { dp[0][i][j] = max(0, grid[0][j] - grid[0][i]); if (i > 0) vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][j])); else vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][j]); } } for (int i = 1; i < N; i++) { for (int j = 0; j <= N; j++) { for (int g = 0; g <= N; g++) { if(g>j){ dp[i][j][g]=grid[i][g]-grid[i][j]+vp[i-1][j][j]; } else{ dp[i][j][g]=vp[i-1][N][j]; } if (j > 0) vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g])); else vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]); } } } long long ans=0; for(int i=0;i<=N;i++){ ans=max(ans,dp[N-1][i][0]); } return ans; }
Compilation message
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)': fish.cpp:21:57: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 21 | dp[0][i][j] = max(0, grid[0][j] - grid[0][i]); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:21:57: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 21 | dp[0][i][j] = max(0, grid[0][j] - grid[0][i]); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:21:57: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 21 | dp[0][i][j] = max(0, grid[0][j] - grid[0][i]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from fish.cpp:3: /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: fish.cpp:21:57: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 21 | dp[0][i][j] = max(0, grid[0][j] - grid[0][i]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from fish.cpp:3: /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: fish.cpp:21:57: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 21 | dp[0][i][j] = max(0, grid[0][j] - grid[0][i]); | ^ fish.cpp:23:91: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 23 | vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][j])); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:23:91: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 23 | vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][j])); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:23:91: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 23 | vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][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 fish.cpp:3: /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: fish.cpp:23:91: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 23 | vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][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 fish.cpp:3: /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: fish.cpp:23:91: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 23 | vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][j])); | ^ fish.cpp:25:70: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 25 | vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][j]); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:25:70: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 25 | vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][j]); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:25:70: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 25 | vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][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 fish.cpp:3: /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: fish.cpp:25:70: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 25 | vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][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 fish.cpp:3: /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: fish.cpp:25:70: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 25 | vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][j]); | ^ fish.cpp:38:99: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 38 | vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g])); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:38:99: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 38 | vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g])); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:38:99: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 38 | vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g])); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from fish.cpp:3: /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: fish.cpp:38:99: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 38 | vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g])); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from fish.cpp:3: /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: fish.cpp:38:99: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 38 | vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g])); | ^ fish.cpp:40:78: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 40 | vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:40:78: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 40 | vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]); | ^ In file included from /usr/include/c++/10/vector:60, from fish.h:1, from fish.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: fish.cpp:40:78: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 40 | vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from fish.cpp:3: /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: fish.cpp:40:78: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 40 | vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from fish.cpp:3: /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: fish.cpp:40:78: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 40 | vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]); | ^