제출 #372935

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

std::string guess_sequence(int N) {
	string p,S;
	char f,s,t;
	if (press("AB") >= 1){
		if (press("A") == 1)
		S+='A';
		else
		S+='B';
	}
	else
	{
		if (press("X") == 1)
		S+='X';
		else
		S+='Y';
	}
	for (int i = 2; i < N; i++){
		p.clear();
		if (S[0] == 'A'){
			p+=S; p+='B';
			p+=S; p+='X'; p+='X';
			p+=S; p+='X'; p+='Y';
			p+=S; p+='X'; p+='B';
			f='B'; s='X'; t='Y';
		}
		if (S[0] == 'B'){
			p+=S; p+='A';
			p+=S; p+='X'; p+='X';
			p+=S; p+='X'; p+='Y';
			p+=S; p+='X'; p+='A';
			f='A'; s='X'; t='Y';
		}
		if (S[0] == 'X'){
			p+=S; p+='A';
			p+=S; p+='B'; p+='B';
			p+=S; p+='B'; p+='Y';
			p+=S; p+='B'; p+='A';
			f='A'; s='B'; t='Y';
		}
		if (S[0] == 'Y'){
			p+=S; p+='A';
			p+=S; p+='B'; p+='B';
			p+=S; p+='B'; p+='X';
			p+=S; p+='B'; p+='A';
			f='A'; s='B'; t='X';
		}
		int ct=press(p);
		if (ct == i)
		S+=f;
		else
		if (ct == i-1)
		S+=t;
		else
		S+=s;
	}
	if (S[0] == 'A'){
		p=S+'B';
		if (press(p) == N)
		return p;
		p=S+'X';
		if (press(p) == N)
		return p;
		p=S+'Y';
		return p;
	}
	if (S[0] == 'B'){
		p=S+'A';
		if (press(p) == N)
		return p;
		p=S+'X';
		if (press(p) == N)
		return p;
		p=S+'Y';
		return p;
	}
	if (S[0] == 'X'){
		p=S+'A';
		if (press(p) == N)
		return p;
		p=S+'B';
		if (press(p) == N)
		return p;
		p=S+'Y';
		return p;
	}
	if (S[0] == 'Y'){
		p=S+'B';
		if (press(p) == N)
		return p;
		p=S+'X';
		if (press(p) == N)
		return p;
		p=S+'A';
		return p;
	}
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:4:2: error: 'string' was not declared in this scope; did you mean 'std::string'?
    4 |  string p,S;
      |  ^~~~~~
      |  std::string
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
combo.cpp:8:3: error: 'S' was not declared in this scope
    8 |   S+='A';
      |   ^
combo.cpp:10:3: error: 'S' was not declared in this scope
   10 |   S+='B';
      |   ^
combo.cpp:15:3: error: 'S' was not declared in this scope
   15 |   S+='X';
      |   ^
combo.cpp:17:3: error: 'S' was not declared in this scope
   17 |   S+='Y';
      |   ^
combo.cpp:20:3: error: 'p' was not declared in this scope
   20 |   p.clear();
      |   ^
combo.cpp:21:7: error: 'S' was not declared in this scope
   21 |   if (S[0] == 'A'){
      |       ^
combo.cpp:28:7: error: 'S' was not declared in this scope
   28 |   if (S[0] == 'B'){
      |       ^
combo.cpp:35:7: error: 'S' was not declared in this scope
   35 |   if (S[0] == 'X'){
      |       ^
combo.cpp:42:7: error: 'S' was not declared in this scope
   42 |   if (S[0] == 'Y'){
      |       ^
combo.cpp:51:3: error: 'S' was not declared in this scope
   51 |   S+=f;
      |   ^
combo.cpp:54:3: error: 'S' was not declared in this scope
   54 |   S+=t;
      |   ^
combo.cpp:56:3: error: 'S' was not declared in this scope
   56 |   S+=s;
      |   ^
combo.cpp:58:6: error: 'S' was not declared in this scope
   58 |  if (S[0] == 'A'){
      |      ^
combo.cpp:59:3: error: 'p' was not declared in this scope
   59 |   p=S+'B';
      |   ^
combo.cpp:68:6: error: 'S' was not declared in this scope
   68 |  if (S[0] == 'B'){
      |      ^
combo.cpp:69:3: error: 'p' was not declared in this scope
   69 |   p=S+'A';
      |   ^
combo.cpp:78:6: error: 'S' was not declared in this scope
   78 |  if (S[0] == 'X'){
      |      ^
combo.cpp:79:3: error: 'p' was not declared in this scope
   79 |   p=S+'A';
      |   ^
combo.cpp:88:6: error: 'S' was not declared in this scope
   88 |  if (S[0] == 'Y'){
      |      ^
combo.cpp:89:3: error: 'p' was not declared in this scope
   89 |   p=S+'B';
      |   ^