제출 #961151

#제출 시각아이디문제언어결과실행 시간메모리
961151raspy콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h"

using namespace std;

string guess_sequence(int N)
{
	char a[5] = {'A', 'B', 'X', 'Y'};
	string p = "";
	for (int i = 0; i < 3; i++)
	{
		p[0] = a[i];
		int odg = press(p);
		if (odg == 1)
		{
			swap(a[i], a[3]);
			break;
		}
		if (i == 3)
			p[0] = a[3];
	}
	char zc = p[0];
	string s = "";
	s += zc;
	for (int tr = 2; tr <= n; tr++)
	{
		p = s + a[0];
		p = p + s+a[1]+a[0];
		p = p + s+a[1]+a[2];
		int odg = press(p);
		if (odg == tr)
			s += a[0];
		else if (odg == tr+1)
			s += a[1];
		else
			s += a[2];
	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:25: error: 'n' was not declared in this scope
   24 |  for (int tr = 2; tr <= n; tr++)
      |                         ^