제출 #109153

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

char ch[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int N)
{
	string s;
	string s1 = "AB";
	string s2 = "A";
	string s3 = "X";

	if(press(s1))
	{
		if(press(s2)) s += 'A';
		else s += 'B';
	}
	else
	{
		if(press(s3)) s += 'X';
		else s += 'Y';
	}

	if(N == 1) return s;

	char ft = s[0];

	vector<string> p;

	if('A' == ft)
	{
		p.push_back("B");
		p.push_back("XB");
		p.push_back("XX");
		p.push_back("XY");
	}
	else if('B' == ft)
	{
		p.push_back("A");
		p.push_back("XA");
		p.push_back("XX");
		p.push_back("XY");
	}
	else if('X' == ft)
	{
		p.push_back("A");
		p.push_back("BA");
		p.push_back("BB");
		p.push_back("BY");
	}
	else
	{
		p.push_back("A");
		p.push_back("BA");
		p.push_back("BB");
		p.push_back("BX");
	}  

	while((int)s.size() < N - 1)
	{
		int t = press(s + p[0] + s + p[1] + s + p[2] + s + p[3]);
		if(t == s.size() + 1) s += p[0];
		else if(t == s.size() + 2) s += p[2][0];
		else s += p[3][1];
	}

	for(int i = 0, t = 0; i < 4; i++, t++)
	{
		if(ch[i] == ft)
		{
			t--;
			continue;
		}
		if(t == 2)
		{
			s += ch[i];
			break;
		}
		if(press(s + ch[i]) > s.size())
		{
			s += ch[i];
			break;
		}

	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:5: error: 'press' was not declared in this scope
   13 |  if(press(s1))
      |     ^~~~~
combo.cpp:61:11: error: 'press' was not declared in this scope
   61 |   int t = press(s + p[0] + s + p[1] + s + p[2] + s + p[3]);
      |           ^~~~~
combo.cpp:62:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   if(t == s.size() + 1) s += p[0];
      |      ~~^~~~~~~~~~~~~~~
combo.cpp:63:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   else if(t == s.size() + 2) s += p[2][0];
      |           ~~^~~~~~~~~~~~~~~
combo.cpp:79:6: error: 'press' was not declared in this scope
   79 |   if(press(s + ch[i]) > s.size())
      |      ^~~~~