제출 #1029969

#제출 시각아이디문제언어결과실행 시간메모리
1029969thabumi콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
using namespace std; string fiAndLa(string pref) { string A = "A"; string B = "B"; string C = "X"; string D = "Y"; string AA = A + A, AB = A + B, AC = A + C, AD = A + D, BA = B + A, BB = B + B, BC = B + C, BD = B + D, CA = C + A, CB = C + B, CC = C + C, CD = C + D, DA = D + A, DB = D + B, DC = D + C, DD = D + D; string res = ""; int coin = press(pref + AB); if (coin > pref.size()) { coin = press(pref + A); if (coin == pref.size() + 1) { res += A; } else { res += B; } } else { coin = press(pref + C); if (coin == pref.size() + 1) { res += C; } else { res += D; } } return res; } std::string guess_sequence(int N) { string A = "A"; string B = "B"; string C = "X"; string D = "Y"; string AA = A + A, AB = A + B, AC = A + C, AD = A + D, BA = B + A, BB = B + B, BC = B + C, BD = B + D, CA = C + A, CB = C + B, CC = C + C, CD = C + D, DA = D + A, DB = D + B, DC = D + C, DD = D + D; string res = ""; int coin; if (N == 1) { res += fiAndLa(res); } else if (N == 2) { res += fiAndLa(res); res += fiAndLa(res); } else { res += fiAndLa(res); string fi = res; for (int i = 2; i <= N - 1; i++) { if (fi == A) { coin = press(res + BB + res + BC + res + BD + res + C); if (coin == res.size() + 2) { res += B; } else if (coin == res.size() + 1) { res += C; } else res += D; } else if (fi == B) { coin = press(res + AA + res + AC + res + AD + res + C); if (coin == res.size() + 2) { res += A; } else if (coin == res.size() + 1) { res += C; } else res += D; } else if (fi == C) { coin = press(res + BB + res + BC + res + BD + res + A); if (coin == res.size() + 2) { res += B; } else if (coin == res.size() + 1) { res += A; } else res += D; } else { coin = press(res + BB + res + BC + res + BD + res + C); if (coin == res.size() + 2) { res += B; } else if (coin == res.size() + 1) { res += C; } else res += A; } } res += fiAndLa(res); } return res; }

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

combo.cpp:2:1: error: 'string' does not name a type
    2 | string fiAndLa(string pref) {
      | ^~~~~~
combo.cpp:33:6: error: 'string' in namespace 'std' does not name a type
   33 | std::string guess_sequence(int N) {
      |      ^~~~~~
combo.cpp:1:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
  +++ |+#include <string>
    1 | using namespace std;