Submission #299650

#TimeUsernameProblemLanguageResultExecution timeMemory
299650TMJNCombo (IOI18_combo)C++17
100 / 100
39 ms604 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

const string C[4]={"A","B","X","Y"};

string guess_sequence(int N) {
	string S;
	int t;
	if(press("AB")){
		if(press("A")){
			t=0;
		}
		else{
			t=1;
		}
	}
	else{
		if(press("X")){
			t=2;
		}
		else{
			t=3;
		}
	}
	S+=C[t];
	if(N==1){
		return S;
	}
	
	for(int i=1;i<N-1;i++){
		string T;
		T+=S+C[(t+1)%4]+C[(t+1)%4]+S+C[(t+1)%4]+C[(t+2)%4]+S+C[(t+1)%4]+C[(t+3)%4]+S+C[(t+2)%4];
		int k=press(T);
		if(k==S.size()){
			S+=C[(t+3)%4];
		}
		else if(k==S.size()+1){
			S+=C[(t+2)%4];
		}
		else{
			S+=C[(t+1)%4];
		}
	}
	for(int i=1;i<=2;i++){
		string T;
		T+=S+C[(t+i)%4];
		if(press(T)==N){
			return T;
		}
	}
	S+=C[(t+3)%4];
	return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:7: 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(k==S.size()){
      |      ~^~~~~~~~~~
combo.cpp:38:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   else if(k==S.size()+1){
      |           ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...