제출 #1131492

#제출 시각아이디문제언어결과실행 시간메모리
1131492YouKnowCipher콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence (int N) {
	string s, t;
	if (press("AB")) {
		if (press("A")) s = "A";
		else s = "B";
	} else {
		if (press("X")) s = "X";
		else s = "Y"; 
	}
	if (N == 1) return s;
	if (s == "A") {
		t[0] = 'B', t[1] = 'X', t[2] = 'Y';
	}
	if (s == "B") {
		t[0] = 'A', t[1] = 'X', t[2] = 'Y';
	}
	if (s == "X") {
		t[0] = 'A', t[1] = 'B', t[2] = 'Y';
	}
	if (s == "Y") {
		t[0] = 'A', t[1] = 'B', t[2] = 'X';
	}
	for (int i = 1; i <= n - 1; i++) {
		string tmp = s + t[0] + t[0] + s + t[0] + t[1] + s + t[0] + t[2] + s + t[1];
		int cost = press(tmp);
		if (cost == i) s += t[2];
		else if (cost == i + 1) s += t[1];
		else s += t[0];
	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:30: error: 'n' was not declared in this scope
   27 |         for (int i = 1; i <= n - 1; i++) {
      |                              ^