제출 #1348560

#제출 시각아이디문제언어결과실행 시간메모리
1348560faqinyeagerCombo (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h"
using namespace std;
string guess_sequence(int n)
{
	string s;
	if(press("AB") > 0){
		if(press["A"] > 0) s = "A";
		else s = "B";
	}else{
		if(press["X"] > 0)) s = "X";
		else s = "Y";
	}
	strin a, b, c;
	if(s == "A") a = "B", b = "X", c = "Y";
	else if(s == "B") a = "A", b = "X", c = "Y";
	else if(s == "X") a = "A", b = "B", c = "Y";
	else a = "A", b = "B", c = "X";
	
	for(int i = 1; i < n; i++){
		int cnt = press(s + a + s + b + a + s + b + b + s + b + c);
		if(cnt == i - 1){
			s += c;
		}else if(cnt == i){
			s += b;
		}else{
			s += a;
		}
	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:25: error: invalid types 'int(std::string) {aka int(std::__cxx11::basic_string<char>)}[const char [2]]' for array subscript
    7 |                 if(press["A"] > 0) s = "A";
      |                         ^
combo.cpp:10:25: error: invalid types 'int(std::string) {aka int(std::__cxx11::basic_string<char>)}[const char [2]]' for array subscript
   10 |                 if(press["X"] > 0)) s = "X";
      |                         ^
combo.cpp:10:35: error: expected primary-expression before ')' token
   10 |                 if(press["X"] > 0)) s = "X";
      |                                   ^
combo.cpp:13:9: error: 'strin' was not declared in this scope; did you mean 'stdin'?
   13 |         strin a, b, c;
      |         ^~~~~
      |         stdin
combo.cpp:14:22: error: 'a' was not declared in this scope
   14 |         if(s == "A") a = "B", b = "X", c = "Y";
      |                      ^
combo.cpp:14:31: error: 'b' was not declared in this scope
   14 |         if(s == "A") a = "B", b = "X", c = "Y";
      |                               ^
combo.cpp:14:40: error: 'c' was not declared in this scope
   14 |         if(s == "A") a = "B", b = "X", c = "Y";
      |                                        ^
combo.cpp:15:27: error: 'a' was not declared in this scope
   15 |         else if(s == "B") a = "A", b = "X", c = "Y";
      |                           ^
combo.cpp:15:36: error: 'b' was not declared in this scope
   15 |         else if(s == "B") a = "A", b = "X", c = "Y";
      |                                    ^
combo.cpp:15:45: error: 'c' was not declared in this scope
   15 |         else if(s == "B") a = "A", b = "X", c = "Y";
      |                                             ^
combo.cpp:16:27: error: 'a' was not declared in this scope
   16 |         else if(s == "X") a = "A", b = "B", c = "Y";
      |                           ^
combo.cpp:16:36: error: 'b' was not declared in this scope
   16 |         else if(s == "X") a = "A", b = "B", c = "Y";
      |                                    ^
combo.cpp:16:45: error: 'c' was not declared in this scope
   16 |         else if(s == "X") a = "A", b = "B", c = "Y";
      |                                             ^
combo.cpp:17:14: error: 'a' was not declared in this scope
   17 |         else a = "A", b = "B", c = "X";
      |              ^
combo.cpp:17:23: error: 'b' was not declared in this scope
   17 |         else a = "A", b = "B", c = "X";
      |                       ^
combo.cpp:17:32: error: 'c' was not declared in this scope
   17 |         else a = "A", b = "B", c = "X";
      |                                ^
combo.cpp:20:37: error: 'a' was not declared in this scope
   20 |                 int cnt = press(s + a + s + b + a + s + b + b + s + b + c);
      |                                     ^
combo.cpp:20:45: error: 'b' was not declared in this scope
   20 |                 int cnt = press(s + a + s + b + a + s + b + b + s + b + c);
      |                                             ^
combo.cpp:20:73: error: 'c' was not declared in this scope
   20 |                 int cnt = press(s + a + s + b + a + s + b + b + s + b + c);
      |                                                                         ^