답안 #716384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
716384 2023-03-29T22:36:09 Z Kahou Growing Vegetable is Fun 3 (JOI19_ho_t3) C++14
컴파일 오류
0 ms 0 KB
/* Ian the name of God, aka Allah */
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
#define mk make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 405;
int n, dp[N][N][N][3];
string s;
vector<int> vc[3];
pii vt[3][N];

void solve() {
        cin >> n;
        cin >> s;
        s = '.'+s;
        for (int i = 1; i <= n; i++) {
                int c = (s[i] != 'R') + (s[i] == 'Y');
                vc[c].push_back(i);
        }
        int a, b, c;
        b = 0, c = 0;
        for (int A = 0; A < (int)vc[0].size(); A++) {
                while (b < (int)vc[1].size() && vc[1][b] < vc[0][A]) b++;
                while (c < (int)vc[2].size() && vc[2][c] < vc[0][A]) c++;
                vt[0][A] = {b, c};
        }
        a = 0, c = 0;
        for (int B = 0; B < (int)vc[1].size(); B++) {
                while (a < (int)vc[0].size() && vc[0][a] < vc[1][B]) a++;
                while (c < (int)vc[2].size() && vc[2][c] < vc[1][B]) c++;
                vt[1][B] = {a, c};
        }
        a = 0, b = 0;
        for (int C = 0; C < (int)vc[2].size(); C++) {
                while (a < (int)vc[0].size() && vc[0][a] < vc[2][C]) a++;
                while (b < (int)vc[1].size() && vc[1][b] < vc[2][C]) b++;
                vt[2][C] = {a, b};
        }
        memset(dp, 64, sizeof dp);
        dp[0][0][0][0] = dp[0][0][0][1] = dp[0][0][0][2] = 0;
        for (int sum = 0; sum < n; sum++) {
                for (int A = 0; A <= min(sum, vc[0].size()); A++) {
                        for (int B = 0; B <= min(sum-A, vc[1].size()); B++) {
                                int C = sum-A-B;
                                if (A < (int)vc[0].size()) {
                                        int b = vt[0][A].F;
                                        int c = vt[0][A].S;
                                        dp[A+1][B][C][0] = min(dp[A+1][B][C][0], min(dp[A][B][C][1], dp[A][B][C][2]) + vc[0][A]+max(B-b, 0)+max(C-c, 0)-(A+B+C+1));
                                }
                                if (B < (int)vc[1].size()) {
                                        int a = vt[1][B].F;
                                        int c = vt[1][B].S;
                                        dp[A][B+1][C][1] = min(dp[A][B+1][C][1], min(dp[A][B][C][0], dp[A][B][C][2]) + vc[1][B]+max(A-a, 0)+max(C-c, 0)-(A+B+C+1));
                                }
                                if (C < (int)vc[2].size()) {
                                        int a = vt[2][C].F;
                                        int b = vt[2][C].S;
                                        dp[A][B][C+1][2] = min(dp[A][B][C+1][2], min(dp[A][B][C][0], dp[A][B][C][1]) + vc[2][C]+max(A-a,0)+max(B-b, 0)-(A+B+C+1));
                                }
                        }
                }
        }
        int ans = 1e9;
        ans = min(dp[vc[0].size()][vc[1].size()][vc[2].size()][0], ans);
        ans = min(dp[vc[0].size()][vc[1].size()][vc[2].size()][1], ans);
        ans = min(dp[vc[0].size()][vc[1].size()][vc[2].size()][2], ans);
        cout << (ans >= 1e9? -1 : ans) << endl;
}

int main() {
        ios::sync_with_stdio(0), cin.tie(0);
        solve();
        return 0;
}

Compilation message

joi2019_ho_t3.cpp: In function 'void solve()':
joi2019_ho_t3.cpp:51:59: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
   51 |                 for (int A = 0; A <= min(sum, vc[0].size()); A++) {
      |                                                           ^
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:5:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:51:59: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   51 |                 for (int A = 0; A <= min(sum, vc[0].size()); A++) {
      |                                                           ^
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:5:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:51:59: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   51 |                 for (int A = 0; A <= min(sum, vc[0].size()); A++) {
      |                                                           ^
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:5:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:51:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |                 for (int A = 0; A <= min(sum, vc[0].size()); A++) {
      |                                                           ^
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:5:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:51:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |                 for (int A = 0; A <= min(sum, vc[0].size()); A++) {
      |                                                           ^
joi2019_ho_t3.cpp:52:69: error: no matching function for call to 'min(int, std::vector<int>::size_type)'
   52 |                         for (int B = 0; B <= min(sum-A, vc[1].size()); B++) {
      |                                                                     ^
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:5:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:52:69: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   52 |                         for (int B = 0; B <= min(sum-A, vc[1].size()); B++) {
      |                                                                     ^
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:5:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:52:69: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   52 |                         for (int B = 0; B <= min(sum-A, vc[1].size()); B++) {
      |                                                                     ^
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:5:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:52:69: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |                         for (int B = 0; B <= min(sum-A, vc[1].size()); B++) {
      |                                                                     ^
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:5:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:52:69: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |                         for (int B = 0; B <= min(sum-A, vc[1].size()); B++) {
      |                                                                     ^