제출 #820125

#제출 시각아이디문제언어결과실행 시간메모리
820125MSK17콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

std::string s;
std::vector<char> c;

std::string make(std::string cur){
	std::string ret;
	for(int i{}; i < 3; ++i){
		ret+=cur;
		ret.push_back(c[0]);
		ret.push_back(c[i]);
	}
	ret+=cur;
	ret.push_back(c[1]);
	return ret;
}

std::string guess_sequence(int n){
	int val=press("AB");
	if(val)
		s=(press("A")==1?"A":"B");
	else
		s=(press("X")==1?"X":"Y");
	std::string all{"ABXY"};
	for(char ch: all)
		if(s[0]!=ch)
			c.push_back(ch);
	while(s.length()<n){
		int k=s.length();
		int cur=press(make(s));
		if(cur==k)
			s.push_back(c[2]);
		else if(cur==k+1)
			s.push_back(c[1]);
		else s.push_back(c[0]);
	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:19:10: error: 'press' was not declared in this scope
   19 |  int val=press("AB");
      |          ^~~~~
combo.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |  while(s.length()<n){
      |        ~~~~~~~~~~^~