제출 #696463

#제출 시각아이디문제언어결과실행 시간메모리
696463Elvin_Fritl콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
 
string guess_sequence(int n) {
	char p=' ';
	string c="";
	vector<char> v(0),b={'A','B','X','Y'};
	int ab=press("AB"),ax=press("AX");
	if (ab&&ax) pre='A';
	else if (ab) pre='B';
	else if (ax) pre='X';
	else p='Y';
	for (char ch:b){
		if (p!=ch) v.push_back(ch);
	}
	c+=p;
	if (n==1) return c;
	for (int i=1;i<n-1;i++){
		string s1=c+v[0],s2=c+v[1];
		string s2a=s2+v[0],s2b=s2+v[1],s2c=s2+v[2];
		int res=press(s1+s2a+s2b+s2c);
		if (res==i+2) c+=v[1];
		else if (res==i+1) c+=v[0];
		else c+=v[2];
	}
	int toto=press(c+v[0]),toto2=press(c+v[1]);
	if (toto1==n) return c+v[0];
	else if (toto2==n) return c+v[1];
	else return c+v[2];
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:10:14: error: 'pre' was not declared in this scope
   10 |  if (ab&&ax) pre='A';
      |              ^~~
combo.cpp:11:15: error: 'pre' was not declared in this scope
   11 |  else if (ab) pre='B';
      |               ^~~
combo.cpp:12:15: error: 'pre' was not declared in this scope
   12 |  else if (ax) pre='X';
      |               ^~~
combo.cpp:28:6: error: 'toto1' was not declared in this scope; did you mean 'toto2'?
   28 |  if (toto1==n) return c+v[0];
      |      ^~~~~
      |      toto2
combo.cpp:27:6: warning: unused variable 'toto' [-Wunused-variable]
   27 |  int toto=press(c+v[0]),toto2=press(c+v[1]);
      |      ^~~~
combo.cpp:7:11: warning: control reaches end of non-void function [-Wreturn-type]
    7 |  string c="";
      |           ^~