제출 #345873

#제출 시각아이디문제언어결과실행 시간메모리
345873Alma콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <string> #include <combo.h> using namespace std; string guess_sequence(int N) { // 100 points: N + 2 calls to "press" string p = ""; string S = ""; vector<char> v = {}; // guess 1st letter of S (num of calls to "press" = 2) p = "AB"; coins = press(p); if (coins >= 1) { p = "A"; coins = press(p); if (coins == 1) {S = "A"; v = {'B', 'X', 'Y'};} // 1st letter = A else {S = "B"; v = {'A', 'X', 'Y'};} // 1st letter = B } else { p = "X"; coins = press(p); if (coins == 1) {S = "X"; v = {'A', 'B', 'Y'};} // 1st letter = X else {S = "Y"; v = {'A', 'B', 'X'};} // 1st letter = Y } // guess from 2nd letter to N-1 (num of calls to "press" = N-2) for (int i = 1; i < N-1; i++) { p = S + v[0]+v[0] + S + v[0]+v[1] + S + v[0]+v[2] + S + v[1]; // f.e. 1st = A p = S BB S BX S BY S X coins = press(p); if (coins == i+2) {S += v[0];} // next letter = B v[0] else if (coins == i+1) {S += v[1];} // next letter = X v[1] else {S += v[2];} // next letter = Y v[2] } // guess last letter of S (num of calls to "press" = 2) p = S + v[0]; coins = press(p); if (coins == N)) {S += v[0];} else { p = S + v[1]; coins = press(p); if (coins == N)) {S += v[1];} else {S += v[2];} } // total of calls to "press" = 2 + N-2 + 2 = N + 2 return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:15: error: 'coins' was not declared in this scope
   15 |     p = "AB"; coins = press(p);
      |               ^~~~~
combo.cpp:40:20: error: expected primary-expression before ')' token
   40 |     if (coins == N)) {S += v[0];}
      |                    ^
combo.cpp:43:24: error: expected primary-expression before ')' token
   43 |         if (coins == N)) {S += v[1];}
      |                        ^