Submission #785353

#TimeUsernameProblemLanguageResultExecution timeMemory
785353khshgCatfish 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, 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:39:40: error: no match for 'operator+' (operand types are 'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} and 'long long int')
   39 |      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)));
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 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_iterator.h:508:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)'
  508 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:508:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 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_iterator.h:1540:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)'
 1540 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1540:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6022:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 6022 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6022:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:56,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1160:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 1160 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1160:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   mismatched types 'const _CharT*' and 'std::map<int, int>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:56,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1180:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 1180 |     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1180:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6059:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 6059 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6059:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6075:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
 6075 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6075:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6087:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 6087 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6087:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6093:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 6093 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6093:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6099:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 6099 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6099:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6121:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 6121 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6121:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   mismatched types 'const _CharT*' and 'std::map<int, int>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6127:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 6127 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6127:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6133:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)'
 6133 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6133:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      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)));
      |                                                      ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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 fish.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6139:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)'
 6139 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6139:5: note:   template argument deduction/substitution failed:
fish.cpp:39:54: note:   'std::map<int, std::map<int, int> >::mapped_type' {aka 'std::map<int, int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |      long long pl = dp[i - 1][pi][ppi] + sum(i + 1, u) - sum(i, min(u, v)) + max(0LL, sum(i - 1,