Submission #785354

#TimeUsernameProblemLanguageResultExecution timeMemory
785354khshgCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { vector<vector<int>> go(N); vector<vector<pair<int, int>>> Ws(N); for(int i = 0; i < M; ++i) { ++Y[i]; if(X[i] - 1 >= 0) go[X[i]].push_back(Y[i]); if(X[i] + 1 < N) go[X[i] + 1].push_back(Y[i]); Ws[X[i]].emplace_back(Y[i], W[i]); } for(auto& u : go) { u.push_back(0); sort(begin(u), end(u)); u.erase(unique(begin(u), end(u)), end(u)); } for(auto& u : Ws) { sort(begin(u), end(u)); u.erase(unique(begin(u), end(u)), end(u)); for(int i = 1; i < (int)u.size(); ++i) { u[i].second += u[i - 1].second; } } auto sum = [&](int x, int y) -> long long { if(x < 0 || x >= N) return 0; auto it = lower_bound(begin(Ws[x]), end(Ws[x]), make_pair(y, 0)); if((*it).first != y) return 0; return (*it).second; }; vector<map<int, map<int, int>>> dp(N); for(int i = 0; i < N; ++i) { for(int ci = 0; ci < (int)go[i].size(); ++ci) { int u = go[i][ci]; if(i - 1 >= 0) for(int pi = 0; pi < (int)go[i - 1].size(); ++pi) { int v = go[i - 1][pi]; if(i - 2 >= 0) for(int ppi = 0; ppi < (int)go[i - 2].size(); ++ppi) { int y = go[i - 2][ppi]; long long pl = dp[i - 1][pi][ppi] + sum(i + 1, u) - sum(i, min(u, v)) + max(0LL, sum(i - 1, u) - sum(i - 1, max(v, y))); dp[i][ci][pi] = max(dp[i][ci][pi], pl); } else { dp[i][ci][pi] = dp[i - 1][pi][0] + sum(i + 1, u) - sum(i, min(u, v)) + max(0LL, sum(i - 1, u) - sum(i - 1, v)); } } else { if(u == 0) continue; dp[i][ci][0] = sum(i - 1, u) + sum(i + 1, u); } } } }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:40:43: error: no matching function for call to 'max(std::map<int, int>::mapped_type&, long long int&)'
   40 |      dp[i][ci][pi] = max(dp[i][ci][pi], pl);
      |                                           ^
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 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:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   40 |      dp[i][ci][pi] = max(dp[i][ci][pi], pl);
      |                                           ^
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 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:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   40 |      dp[i][ci][pi] = max(dp[i][ci][pi], pl);
      |                                           ^
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: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:
fish.cpp:40:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |      dp[i][ci][pi] = max(dp[i][ci][pi], pl);
      |                                           ^
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: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:
fish.cpp:40:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |      dp[i][ci][pi] = max(dp[i][ci][pi], pl);
      |                                           ^
fish.cpp:50:1: warning: no return statement in function returning non-void [-Wreturn-type]
   50 | }
      | ^