Submission #741750

#TimeUsernameProblemLanguageResultExecution timeMemory
741750MODDICombo (IOI18_combo)C++14
0 / 100
0 ms208 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
std::string guess_sequence(int n) {
	string str;
	if(press("AB")){
		if(press("A"))	str += "A";
		else str += "B";
	}
	else{
		if(press("X"))	str += "X";
		else str += "Y";
	}
	if(n==1)	return str;
	while(str.size() < n-1){
		int val = press(str + "B" + str + "XB" + str + "XX" + str + "XY");
		if(val == str.size()){
			str += "Y";
		}
		else if(val == str.size()+1){
			str += "B";
		}
		else if(val == str.size()+2)
			str += "X";
		else
			str += "A";
	}
	for(int j = 0; j < 2; j++){
		str.pb(char(j+'A'));
		if(press(str) == n)	return str;
	
		str.pop_back();
	}
	str.pb('Y');
	return str;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |  while(str.size() < n-1){
      |        ~~~~~~~~~~~^~~~~
combo.cpp:18:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(val == str.size()){
      |      ~~~~^~~~~~~~~~~~~
combo.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   else if(val == str.size()+1){
      |           ~~~~^~~~~~~~~~~~~~~
combo.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   else if(val == str.size()+2)
      |           ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...