답안 #116444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116444 2019-06-12T13:09:17 Z 송준혁(#2869, songc) Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1234567890
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N;
char str[440];
vector<int> R, G, Y;
int D[4][404][404][404];

int f(int l, int r, int g, int y){
    if (r+g+y >= N) return 0;
    if (D[l][r][g][y] != INF) return D[l][r][g][y];
    if (l != 0 && r < (int)R.size()){
        int ret = f(0, r+1, g, y);
        ret += max(0, g - (lower_bound(G.begin(), G.end(), R[r]) - G.begin()));
        ret += max(0, y - (lower_bound(Y.begin(), Y.end(), R[r]) - Y.begin()));
        D[l][r][g][y] = min(D[l][r][g][y], ret);
    }
    if (l != 1 && g < (int)G.size()){
        int ret = f(1, r, g+1, y);
        ret += max(0, r - (lower_bound(R.begin(), R.end(), G[g]) - R.begin()));
        ret += max(0, y - (lower_bound(Y.begin(), Y.end(), G[g]) - Y.begin()));
        D[l][r][g][y] = min(D[l][r][g][y], ret);
    }
    if (l != 2 && y < (int)Y.size()){
        int ret = f(2, r, g, y+1);
        ret += max(0, r - (lower_bound(R.begin(), R.end(), Y[y]) - R.begin()));
        ret += max(0, g - (lower_bound(G.begin(), G.end(), Y[y]) - G.begin()));
        D[l][r][g][y] = min(D[l][r][g][y], ret);
    }
    return D[l][r][g][y];
}

int main(){
    scanf("%d", &N);
    scanf("%s", str+1);
    for (int i=1; i<=N; i++){
        if (str[i] == 'R') R.push_back(i);
        else if (str[i] == 'G') G.push_back(i);
        else Y.push_back(i);
    }
    for (int i=0; i<4; i++){
        for (int j=0; j<=(int)R.size(); j++){
            for (int k=0; k<=(int)G.size(); k++){
                for (int l=0; l<=(int)Y.size(); l++){
                    D[i][j][k][l] = INF;
                }
            }
        }
    }
    int ans = f(3, 0, 0, 0);
    if (ans == INF) puts("-1");
    else printf("%d\n", ans);
    return 0;
}

Compilation message

joi2019_ho_t3.cpp: In function 'int f(int, int, int, int)':
joi2019_ho_t3.cpp:18:78: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
         ret += max(0, g - (lower_bound(G.begin(), G.end(), R[r]) - G.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:18:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, g - (lower_bound(G.begin(), G.end(), R[r]) - G.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:18:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, g - (lower_bound(G.begin(), G.end(), R[r]) - G.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:18:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, g - (lower_bound(G.begin(), G.end(), R[r]) - G.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:18:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, g - (lower_bound(G.begin(), G.end(), R[r]) - G.begin()));
                                                                              ^
joi2019_ho_t3.cpp:19:78: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), R[r]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:19:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), R[r]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:19:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), R[r]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:19:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), R[r]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:19:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), R[r]) - Y.begin()));
                                                                              ^
joi2019_ho_t3.cpp:24:78: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
         ret += max(0, r - (lower_bound(R.begin(), R.end(), G[g]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:24:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, r - (lower_bound(R.begin(), R.end(), G[g]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:24:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, r - (lower_bound(R.begin(), R.end(), G[g]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:24:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, r - (lower_bound(R.begin(), R.end(), G[g]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:24:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, r - (lower_bound(R.begin(), R.end(), G[g]) - R.begin()));
                                                                              ^
joi2019_ho_t3.cpp:25:78: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), G[g]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:25:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), G[g]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:25:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), G[g]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:25:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), G[g]) - Y.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:25:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, y - (lower_bound(Y.begin(), Y.end(), G[g]) - Y.begin()));
                                                                              ^
joi2019_ho_t3.cpp:30:78: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
         ret += max(0, r - (lower_bound(R.begin(), R.end(), Y[y]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:30:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, r - (lower_bound(R.begin(), R.end(), Y[y]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:30:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, r - (lower_bound(R.begin(), R.end(), Y[y]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:30:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, r - (lower_bound(R.begin(), R.end(), Y[y]) - R.begin()));
                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:30:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         ret += max(0, r - (lower_bound(R.begin(), R.end(), Y[y]) - R.begin()));
                                                                              ^
joi2019_ho_t3.cpp:31:78: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
         ret += max(0, g - (lower_bound(G.begin(), G.end(), Y[y]) - G.begin()));
                                                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:31:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}')
         ret += max(0, g - (lower_bound(G.begin(), G.end(), Y[y]) - G.begin()));
                                                                              ^
In file in