Submission #914354

# Submission time Handle Problem Language Result Execution time Memory
914354 2024-01-21T17:59:44 Z Keys Growing Vegetable is Fun 3 (JOI19_ho_t3) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
using vi = vector<int>;
#define pb push_back
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
template <class T> istream &operator>>(istream& in, vector<T> &v) {for (auto& i : v) in >> i; return in;}

#ifdef LOCAL
#include "../../../lib/debug.h"
#else
#define dbg(...)
#endif

const int N=405,oo=1e18;
int dp[N][N][N][3];
int p[3][N];
int cnt[3];
map<char,int>m;

void ckmin(int &a, int b) {
  a = min(a, b);
}

signed main() {
  ios::sync_with_stdio(0);cin.tie(0);m['R']=0;m['G']=1;m['Y']=2;
  int n;cin>>n;string s;cin>>s;
  FOR(i,0,n)cnt[m[s[i]]]++;
  vi y={0,0,0};
  FOR(i,0,n){
    y[m[s[i]]]++;
    p[m[s[i]]][y[m[s[i]]]]=i;
  }
//  FOR(i,0,3){FOR(j,0,n)cout<<p[i][j]<<' ';cout<<endl;}
  FOR(i,0,N)FOR(j,0,N)FOR(k,0,N)FOR(l,0,3)dp[i][j][k][l]=oo;FOR(i,0,3)dp[0][0][0][i]=1;
  FOR(i,0,cnt[0]+1)FOR(j,0,cnt[1]+1)FOR(k,0,cnt[2]+1)FOR(last,0,3)FOR(next,0,3)if(last!=next){
    vi x={i,j,k};if(x[next]==cnt[next])continue;
    x[next]++;
    ckmin(dp[x[0]][x[1]][x[2]][next],dp[i][j][k][last]+max(0ll,p[next][x[next]]-(i+j+k)));
  }
  int ans=min({dp[cnt[0]][cnt[1]][cnt[2]][0], dp[cnt[0]][cnt[1]][cnt[2]][1], dp[cnt[0]][cnt[1]][cnt[2]][2]});
  if(ans==oo)cout<<-1<<endl;
  else cout<<ans-1<<endl;
}

Compilation message

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:43:88: error: no matching function for call to 'max(long long int, int64_t)'
   43 |     ckmin(dp[x[0]][x[1]][x[2]][next],dp[i][j][k][last]+max(0ll,p[next][x[next]]-(i+j+k)));
      |                                                                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 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:43:88: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   43 |     ckmin(dp[x[0]][x[1]][x[2]][next],dp[i][j][k][last]+max(0ll,p[next][x[next]]-(i+j+k)));
      |                                                                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 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:43:88: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   43 |     ckmin(dp[x[0]][x[1]][x[2]][next],dp[i][j][k][last]+max(0ll,p[next][x[next]]-(i+j+k)));
      |                                                                                        ^
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:43:88: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |     ckmin(dp[x[0]][x[1]][x[2]][next],dp[i][j][k][last]+max(0ll,p[next][x[next]]-(i+j+k)));
      |                                                                                        ^
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:43:88: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |     ckmin(dp[x[0]][x[1]][x[2]][next],dp[i][j][k][last]+max(0ll,p[next][x[next]]-(i+j+k)));
      |                                                                                        ^