Submission #546128

#TimeUsernameProblemLanguageResultExecution timeMemory
546128jamezzzCombo (IOI18_combo)C++17
100 / 100
31 ms600 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N){
	string S="";
	if(press("AB")){
		if(press("A"))S+="A";
		else S+="B";
	}
	else{
		if(press("X"))S+="X";
		else S+="Y";
	}
	
	vector<string> v;
	if(S!="A")v.push_back("A");
	if(S!="B")v.push_back("B");
	if(S!="X")v.push_back("X");
	if(S!="Y")v.push_back("Y");
	
	for(int i=1;i<N-1;++i){
		int res=press(S+v[0]+v[0]+S+v[0]+v[1]+S+v[0]+v[2]+S+v[1]);
		if(res==S.length())S+=v[2];
		else if(res==S.length()+1)S+=v[1];
		else S+=v[0];
	}
	
	if(N>1){
		if(press(S+"A"+S+"B")==S.length()+1){
			if(press(S+"A")==S.length()+1)S+="A";
			else S+="B";
		}
		else{
			if(press(S+"X")==S.length()+1)S+="X";
			else S+="Y";
		}
	}
	
	return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if(res==S.length())S+=v[2];
      |      ~~~^~~~~~~~~~~~
combo.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   else if(res==S.length()+1)S+=v[1];
      |           ~~~^~~~~~~~~~~~~~
combo.cpp:30:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if(press(S+"A"+S+"B")==S.length()+1){
      |      ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:31:19: 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(press(S+"A")==S.length()+1)S+="A";
      |       ~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |    if(press(S+"X")==S.length()+1)S+="X";
      |       ~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...