Submission #1111888

#TimeUsernameProblemLanguageResultExecution timeMemory
1111888nikolashamiCombo (IOI18_combo)C++17
100 / 100
50 ms2056 KiB
#include<bits/stdc++.h>
using namespace std;
 
#include "combo.h"
 
string qs;
int q;
 
string guess_sequence(int N){
	int n=N;
	char prvi;
    qs="ABAB";
 	q=press(qs);
	if(!q){
		qs="X";
		if(press(qs))
			prvi='X';
		else
			prvi='Y';
	}else{
		qs="A";
		if(press(qs))
			prvi='A';
		else
			prvi='B';
	}
	qs.clear();
	qs.push_back(prvi);
	vector<char>v={'A','B','X','Y'};
	v.erase(find(v.begin(),v.end(),prvi));
	if(n==1)
      	return qs;
	while(qs.size()<n-1){
		string cur=qs;
		cur+=v[0];
		cur+=v[1];
		cur+=qs;
		cur+=v[0];
		cur+=v[2];
		cur+=qs;
		cur+=v[0];
		cur+=v[0];
		cur+=qs;
		cur+=v[1];
		q=press(cur)-qs.size();
		if(!q)
			qs.push_back(v[2]);
		else if(q==1)
			qs.push_back(v[1]);
		else
			qs.push_back(v[0]);
	}
    string tmp=qs;
    tmp+=v[0];
    tmp+=qs;
    tmp+=v[1];
    q=press(tmp)-qs.size();
    if(q){
        tmp.clear();
        tmp+=qs;
        tmp+=v[0];
        if(press(tmp)-qs.size())
            qs.push_back(v[0]);
        else
            qs.push_back(v[1]);
    }else
        qs.push_back(v[2]);
	return qs;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |  while(qs.size()<n-1){
      |        ~~~~~~~~~^~~~
combo.cpp:66:6: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   66 |     }else
      |      ^~~~
combo.cpp:68:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   68 |  return qs;
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...