Submission #138264

#TimeUsernameProblemLanguageResultExecution timeMemory
138264Lawliet콤보 (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

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

int N;

string S;
string remain;

int getInd(char a)
{
	for(int g = 0 ; g < 4 ; g++)
		if(buttons[g] == a) return g;
}

/*int press(string p)
{
	//for(int g = 0 ; g < 4 ; g++)
		//printf("%d -> %c\n",g,p[g]);
	printf("-> %s\n",p.c_str());

	int a;
	scanf("%d",&a);

	return a;
}*/

void getFirstButton()
{
	if( press("AB") >= 1 )
	{
		if( press("A") == 1 ) S = "A";
		else S = "B";
	}
	else
	{
		if( press("C") == 1 ) S = "C";
		else S = "D";
	}
}

string guess_sequence(int n)
{
	N = n;

	getFirstButton();

	for(int h = 0 ; h < 4 ; h++)
		if(buttons[h] != S[0])
			remain = remain + buttons[h];

	for(int g = 1 ; g < N ; g++)
	{
		int cnt = 0;
		//printf("n = %d    %d\n",n,N);

		//printf("ççç %s\n",re)

		for(int h = 0 ; h < 2 ; h++)
		{
			//printf("S = %s    %d\n",S.c_str(),S.size());
			S.push_back(remain[h]);
			//string k = S + remain[h];
			//printf("=== %s\n",S.c_str());
			if(press(S) == S.size()) break;
			S.pop_back();
		}

		if(S.size() == g)
			S = S + remain[2];
	}

	return S;
}

/*int main()
{
	int nn;

	scanf("%d",&nn);

	cout << guess_sequence( nn ) << endl;
}*/

Compilation message (stderr)

combo.cpp: In function 'void getFirstButton()':
combo.cpp:32:6: error: 'press' was not declared in this scope
   32 |  if( press("AB") >= 1 )
      |      ^~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:67:7: error: 'press' was not declared in this scope
   67 |    if(press(S) == S.size()) break;
      |       ^~~~~
combo.cpp:71:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |   if(S.size() == g)
      |      ~~~~~~~~~^~~~
combo.cpp:56:7: warning: unused variable 'cnt' [-Wunused-variable]
   56 |   int cnt = 0;
      |       ^~~
combo.cpp: In function 'int getInd(char)':
combo.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
   16 | }
      | ^