Submission #915316

#TimeUsernameProblemLanguageResultExecution timeMemory
915316ace5Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 400; #define int int64_t const int INF = 1e18; vector<int> pos[3]; vector<vector<vector<int>>> dp[3]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; for(int j = 0;j < n;++j) { if(s[j] == 'R') { pos[0].push_back(j); } else if(s[j] == 'G') { pos[1].push_back(j); } else pos[2].push_back(j); } for(int i = 0;i < 3;++i) { dp[i].resize(pos[0].size()+1); for(int j= 0;j < dp[i].size();++j) { dp[i][j].resize(pos[1].size()+1); for(int k = 0;k < dp[i][j].size();++k) { dp[i][j][k].resize(pos[2].size()+1); } } } int k[3] = {0}; for(k[0] = 0;k[0] <= pos[0].size();++k[0]) { for(k[1] = 0;k[1] <= pos[1].size();++k[1]) { for(k[2] = 0;k[2] <= pos[2].size();++k[2]) { for(int last = 0;last < 3;++last) { auto &cdp = dp[last][k[0]][k[1]][k[2]]; if(k[0]+k[1]+k[2] == 0) { cdp = 0; continue; } cdp = INF; if(k[last] != 0) { int cpos = pos[last][k[last]-1]; int ind0 = upper_bound(pos[0].begin(),pos[0].end(),cpos)-pos[0].begin(); int ind1 = upper_bound(pos[1].begin(),pos[1].end(),cpos)-pos[1].begin(); int ind2 = upper_bound(pos[2].begin(),pos[2].end(),cpos)-pos[2].begin(); int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2); k[last]--; for(int nlast = 0;nlast < 3;++nlast) { if(nlast != last) { cdp = min(cdp,c + dp[nlast][k[0]][k[1]][k[2]]); } } k[last]++; } } } } } int ans = INF; for(int le = 0;le < 3;++le) ans = min(ans,dp[le][pos[0].size()][pos[1].size()][pos[2].size()]); cout << (ans == INF ? -1 : ans); return 0; }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::vector<std::vector<long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int j=  0;j < dp[i].size();++j)
      |                       ~~^~~~~~~~~~~~~~
joi2019_ho_t3.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::vector<long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for(int k = 0;k < dp[i][j].size();++k)
      |                           ~~^~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(k[0] = 0;k[0] <= pos[0].size();++k[0])
      |                  ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:50:27: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(k[1] = 0;k[1] <= pos[1].size();++k[1])
      |                      ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for(k[2] = 0;k[2] <= pos[2].size();++k[2])
      |                          ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:69:50: error: no matching function for call to 'max(long long int, int64_t)'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                  ^
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 joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:50: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                  ^
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 joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:50: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                  ^
joi2019_ho_t3.cpp:69:71: error: no matching function for call to 'max(long long int, int64_t)'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                       ^
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 joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:71: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                       ^
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 joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:71: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:71: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:71: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                       ^
joi2019_ho_t3.cpp:69:92: error: no matching function for call to 'max(long long int, int64_t)'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                                            ^
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 joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:92: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                                            ^
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 joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:92: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:92: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from joi2019_ho_t3.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:
joi2019_ho_t3.cpp:69:92: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         int c = max(0ll,k[0]-ind0) + max(0ll,k[1]-ind1) + max(0ll,k[2]-ind2);
      |                                                                                            ^