답안 #341625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341625 2020-12-30T09:38:08 Z BlancaHM 콤보 (IOI18_combo) C++14
컴파일 오류
0 ms 0 KB
#include "combo.h"
using namespace std;
 
string guess_sequence(int N) {
	string S;
	char first;
	int x = press("AB");
	if (x == 2) {
		S = "AB";
		first = 'A';
	} else if (x == 1) {
		x = press("A");
		if (x) {
			first = 'A';
			S = "A";
		}
		else {
			first = 'B';
			S = "B";
		}
	} else {
		x = press("X");
		if (x) {
			first = 'X';
			S = "X";
		} else {
			first = 'Y';
			S = "Y";
		}
	}
	vector<string> pos;
	if (first != 'A') pos.push_back("A");
	if (first != 'B') pos.push_back("B");
	if (first != 'X') pos.push_back("X");
	if (first != 'Y') pos.push_back("Y");
	while((int) S.length() < N) {
		if (3*((int) S.length() + 2) + (int) S.length() + 1 <= 4*N) {
			x = press(S + pos[0] + pos[0] + S + pos[0] + pos[1] + S + pos[0] + pos[2] + S + pos[1]);
			if (x == (int) S.length() + 2) S += pos[0];
			else if (x == (int) S.length() + 1) S += pos[1];
			else S += pos[2];
		} else {
			x = press(S + pos[0]);
			if(x == (int) S.length() + 1) {
				S += pos[0];
				continue;
			}
			x = press(S + pos[1]);
			if (x == (int) S.length() + 1) S += pos[1];
			else S += pos[2];
		}
	}
	return S;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:2: error: 'vector' was not declared in this scope
   31 |  vector<string> pos;
      |  ^~~~~~
combo.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "combo.h"
  +++ |+#include <vector>
    2 | using namespace std;
combo.cpp:31:15: error: expected primary-expression before '>' token
   31 |  vector<string> pos;
      |               ^
combo.cpp:31:17: error: 'pos' was not declared in this scope
   31 |  vector<string> pos;
      |                 ^~~