Submission #299642

#TimeUsernameProblemLanguageResultExecution timeMemory
299642TMJNCombo (IOI18_combo)C++17
0 / 100
3 ms488 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=3;
	for(int i=0;i<3;i++){
		if(press(C[i]))t=i;
	}
	for(int i=1;i<N;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<=3;i++){
		string T;
		T+=S+C[(t+i)%4];
		if(press(T)==N){
			return T;
		}
	}
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   if(k==S.size()){
      |      ~^~~~~~~~~~
combo.cpp:20:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   else if(k==S.size()+1){
      |           ~^~~~~~~~~~~~
combo.cpp:8:9: warning: control reaches end of non-void function [-Wreturn-type]
    8 |  string S;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...