Submission #864862

#TimeUsernameProblemLanguageResultExecution timeMemory
864862n1kCombo (IOI18_combo)C++17
5 / 100
1 ms596 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

/*
XYYABYABAY
*/

std::string guess_sequence(int N) {
	// find first char
	// in one op
	string first, guess = "AB", s = "";
	if(press(guess)){
		first = press("A") ? "A" : "B";
	}else{
		first = press("X") ? "X" : "Y";
	}
	s = first;
	
	vector<string> vorrat = {"A", "B", "X", "Y"};
	vorrat.erase(find(vorrat.begin(), vorrat.end(), first));


	// guess next char
	while(s.size() < N - 1){
		guess = s + vorrat[0];
		for(auto x: vorrat){
			guess += s + vorrat[1] + x;
		}
		int c = press(guess);
		if(c == s.size() + 1){
			s += vorrat[0];
		}else if(c == s.size() + 2){
			s += vorrat[1];
		}else{
			s += vorrat[2];
		}
	}

	if(s.size() < press(s + vorrat[0])){
		s += vorrat[0];
	}else if(s.size() < press(s + vorrat[1])){
		s += vorrat[1];
	}else{
		s += vorrat[2];
	}

	return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
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 |  while(s.size() < N - 1){
      |        ~~~~~~~~~^~~~~~~
combo.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(c == s.size() + 1){
      |      ~~^~~~~~~~~~~~~~~
combo.cpp:34:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   }else if(c == s.size() + 2){
      |            ~~^~~~~~~~~~~~~~~
combo.cpp:41:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |  if(s.size() < press(s + vorrat[0])){
      |     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
combo.cpp:43:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |  }else if(s.size() < press(s + vorrat[1])){
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...