제출 #1275193

#제출 시각아이디문제언어결과실행 시간메모리
1275193nanaseyuzukiGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> // Author: Kazuki_Will_Win_VOI_8703 #define fi first #define se second #define pii pair<int, int> #define ll long long #define all(a) a.begin(), a.end() using namespace std; const int mn = 405 + 5, bm = (1 << 11) + 1, mod = 1e9 + 7, offset = 5e4, B = 320 + 5; const int inf = 1e9, base = 311; int n, prefix[mn][3]; string s; vector <int> pos[mn]; int dp[405][405][405][4]; int f(int i, int j, int k, int pre){ if(i + j + k == n) return 0; if(dp[i][j][k][pre] != -1) return dp[i][j][k][pre]; dp[i][j][k][pre] = inf; for(int nxt = 0; nxt <= 2; nxt ++){ if(nxt == pre) continue; int cost = 0; int p, newi, newj, newk; if(nxt == 0){ if(i + 1 > pos[nxt].size() - 1) continue; p = pos[0][i + 1]; newi = i + 1, newj = j, newk = k; } if(nxt == 1){ if(j + 1 > pos[nxt].size() - 1) continue; p = pos[nxt][j + 1]; newi = i, newj = j + 1, newk = k; } if(nxt == 2){ if(k + 1 > pos[nxt].size() - 1) continue; p = pos[2][k + 1]; newi = i, newj = j, newk = k + 1; } for(int col = 0; col <= 2; col ++){ if(col == nxt) continue; if(col == 0) cost += max(0ll, prefix[p][col] - i); if(col == 1) cost += max(0ll, prefix[p][col] - j); if(col == 2) cost += max(0ll, prefix[p][col] - k); } dp[i][j][k][pre] = min(dp[i][j][k][pre], f(newi, newj, newk, nxt) + cost); } return dp[i][j][k][pre]; } void solve(){ cin >> n >> s; s = "#" + s; for(int i = 0; i <= 2; i++) pos[i].push_back(0); for(int i = 1; i <= n; i++){ for(int j = 0; j <= 2; j++) prefix[i][j] = prefix[i - 1][j]; if(s[i] == 'G'){ prefix[i][0] ++; pos[0].push_back(i); } if(s[i] == 'R'){ prefix[i][1] ++; pos[1].push_back(i); } if(s[i] == 'Y'){ prefix[i][2] ++; pos[2].push_back(i); } } for(int i = 0; i <= pos[0].size() - 1; i ++){ for(int j = 0; j <= pos[1].size() - 1; j++){ for(int k = 0; k <= pos[2].size() - 1; k++){ for(int pre = 0; pre <= 3; pre ++){ dp[i][j][k][pre] = -1; } } } } cout << f(0, 0, 0, 3) << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; // cin >> t; while(t --){ solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t3.cpp: In function 'int f(int, int, int, int)':
joi2019_ho_t3.cpp:46:37: error: no matching function for call to 'max(long long int, int)'
   46 |             if(col == 0) cost += max(0ll, prefix[p][col] - i);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from joi2019_ho_t3.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:46:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |             if(col == 0) cost += max(0ll, prefix[p][col] - i);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:46:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |             if(col == 0) cost += max(0ll, prefix[p][col] - i);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:46:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |             if(col == 0) cost += max(0ll, prefix[p][col] - i);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:46:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |             if(col == 0) cost += max(0ll, prefix[p][col] - i);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:47:37: error: no matching function for call to 'max(long long int, int)'
   47 |             if(col == 1) cost += max(0ll, prefix[p][col] - j);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:47:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |             if(col == 1) cost += max(0ll, prefix[p][col] - j);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:47:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |             if(col == 1) cost += max(0ll, prefix[p][col] - j);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:47:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |             if(col == 1) cost += max(0ll, prefix[p][col] - j);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:47:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |             if(col == 1) cost += max(0ll, prefix[p][col] - j);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:48:37: error: no matching function for call to 'max(long long int, int)'
   48 |             if(col == 2) cost += max(0ll, prefix[p][col] - k);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:48:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |             if(col == 2) cost += max(0ll, prefix[p][col] - k);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:48:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |             if(col == 2) cost += max(0ll, prefix[p][col] - k);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:48:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |             if(col == 2) cost += max(0ll, prefix[p][col] - k);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
joi2019_ho_t3.cpp:48:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |             if(col == 2) cost += max(0ll, prefix[p][col] - k);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~