제출 #819822

#제출 시각아이디문제언어결과실행 시간메모리
819822canadavid1Miners (IOI07_miners)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using i8 = int8_t; vector<array<int,256>> dp; int produce(i8 a,i8 b,i8 c) { bool s[4]{}; s[a] = true; s[b] = true; s[c] = true; return ((int)s[1]) + ((int)s[2]) + ((int)s[3]); } int toidx(pair<i8,i8> h1,pair<i8,i8> h2) { //if(!h1.first || !h1.second || !h2.first || !h2.second) return 0; return 4*4*4*h1.first + 4*4*h1.second + 4*h2.first + h2.second; } int toid(char s) { switch(s) { case 'B': return 1; case 'M': return 2; case 'F': return 3; default: __builtin_unreachable(); } } int ct = 0; int mct = 0; int best(int off,string_view s,pair<i8,i8> h1={0,0}, pair<i8,i8> h2={0,0}) { if(off >= s.size()) return 0; ct++; if (dp[off][toidx(h1,h2)]) return dp[off][toidx(h1,h2)]; mct++; int max_produce = -1; // h1 pair<i8,i8> h1p = {h1.second,toid(s[off])}; max_produce = max(max_produce,produce(h1.first,h1.second,toid(s[off]))+best(off+1,s,h1p,h2)); pair<i8,i8> h2p = {h2.second,toid(s[off])}; max_produce = max(max_produce,produce(h2.first,h2.second,toid(s[off]))+best(off+1,s,h1,h2p)); dp[off][toidx(h1,h2)] = max_produce; return max_produce; } int main() { int N; cin >> N; string s(N,'\0'); dp.assign(N,array<int,256>{}); for(auto &&i : s) cin >> i; cout << best(0,s) << "\n"; //cout << ct << " " << mct << "\n"; }

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

miners.cpp:33:18: error: 'string_view' has not been declared
   33 | int best(int off,string_view s,pair<i8,i8> h1={0,0}, pair<i8,i8> h2={0,0})
      |                  ^~~~~~~~~~~
miners.cpp: In function 'int best(int, int, std::pair<signed char, signed char>, std::pair<signed char, signed char>)':
miners.cpp:35:17: error: request for member 'size' in 's', which is of non-class type 'int'
   35 |     if(off >= s.size()) return 0;
      |                 ^~~~
miners.cpp:41:40: error: invalid types 'int[int]' for array subscript
   41 |     pair<i8,i8> h1p = {h1.second,toid(s[off])};
      |                                        ^
miners.cpp:41:46: error: could not convert '{h1.std::pair<signed char, signed char>::second, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<signed char, signed char>'
   41 |     pair<i8,i8> h1p = {h1.second,toid(s[off])};
      |                                              ^
      |                                              |
      |                                              <brace-enclosed initializer list>
miners.cpp:42:68: error: invalid types 'int[int]' for array subscript
   42 |     max_produce = max(max_produce,produce(h1.first,h1.second,toid(s[off]))+best(off+1,s,h1p,h2));
      |                                                                    ^
miners.cpp:43:40: error: invalid types 'int[int]' for array subscript
   43 |     pair<i8,i8> h2p = {h2.second,toid(s[off])};
      |                                        ^
miners.cpp:43:46: error: could not convert '{h2.std::pair<signed char, signed char>::second, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<signed char, signed char>'
   43 |     pair<i8,i8> h2p = {h2.second,toid(s[off])};
      |                                              ^
      |                                              |
      |                                              <brace-enclosed initializer list>
miners.cpp:44:68: error: invalid types 'int[int]' for array subscript
   44 |     max_produce = max(max_produce,produce(h2.first,h2.second,toid(s[off]))+best(off+1,s,h1,h2p));
      |                                                                    ^
miners.cpp: In function 'int main()':
miners.cpp:57:20: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int'
   57 |     cout << best(0,s) << "\n";
      |                    ^
      |                    |
      |                    std::string {aka std::__cxx11::basic_string<char>}
miners.cpp:33:30: note:   initializing argument 2 of 'int best(int, int, std::pair<signed char, signed char>, std::pair<signed char, signed char>)'
   33 | int best(int off,string_view s,pair<i8,i8> h1={0,0}, pair<i8,i8> h2={0,0})
      |                  ~~~~~~~~~~~~^