Submission #863083

#TimeUsernameProblemLanguageResultExecution timeMemory
863083maks007Combo (IOI18_combo)C++14
97 / 100
14 ms2028 KiB
#include "combo.h"
#include "bits/stdc++.h"
//#include "grader.cpp"

using namespace std;

string guess_sequence(int n) {
	string str = "", abxy;
	str += 'A';
	if(press(str) == 1) goto end;
	str.pop_back();
	str += 'B';
	if(press(str) == 1) goto end;
	str.pop_back();
	str += 'X';
	if(press(str) == 1) goto end;
	str.pop_back();
	str += 'Y';
	end:;
	if(str.size() == n) return str;
	if(str[0] == 'X') abxy = "ABY";
	else if(str[0] == 'A') abxy = "BXY";
	else if(str[0] == 'Y') abxy = "ABX";
	else abxy = "AXY";
	while(1) {
		if(str.size() == n - 1) break;
		string forPress;
		forPress += str + abxy[0];
		forPress += str + abxy[1] + abxy[0] + str + abxy[1] + abxy[1] + str + abxy[1] + abxy[2];
		int cnt = press(forPress);
		if(cnt == str.size() + 1) str += abxy[0];
		else if(cnt == str.size() + 2) str += abxy[1];
		else str += abxy[2];
	}
	if(press(str + abxy[0]) == n) str += abxy[0];
	else if(press(str + abxy[1]) == n) str += abxy[1];
	else str += abxy[2];
	return str;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  if(str.size() == n) return str;
      |     ~~~~~~~~~~~^~~~
combo.cpp:26:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |   if(str.size() == n - 1) break;
      |      ~~~~~~~~~~~^~~~~~~~
combo.cpp:31:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if(cnt == str.size() + 1) str += abxy[0];
      |      ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   else if(cnt == str.size() + 2) str += abxy[1];
      |           ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...