Submission #138425

#TimeUsernameProblemLanguageResultExecution timeMemory
138425degeloCombo (IOI18_combo)C++17
100 / 100
54 ms472 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
string a[4]; 
int first;
string s;
/*int press(string a){
	int resp;
	cout<<a;
	cin>>resp;
	return resp;
}*/
string guess_sequence(int n){
	a[0]="A",a[1]="B",a[2]="X",a[3]="Y";
	if(press(a[0]+a[1])>=1){
		if(press(a[0])==1){
			first=0;
			s+=a[0];
		}
		else{
			first=1;
			s+=a[1];	
		}
	}
	else{
		if(press(a[2])==1){
			first=2;
			s+=a[2];
		}
		else{
			first=3;
			s+=a[3];
		}
	}
	vector<string> b;
	for(int i=0;i<4;i++){
		if(i!=first) b.push_back(a[i]);
	}
	for(int i=1;i<n-1;i++){
		string st=s+b[0]+b[0]+s+b[0]+b[1]+s+b[0]+b[2]+s+b[1];
		int t=press(st);
		if(t==s.size()){
			s+=b[2];
		}
		if(t==s.size()+1){
			s+=b[1];
		}
		if(t==s.size()+2){
			s+=b[0];
		}
	}
	if(n>1){
		if(press(s+b[0])==n) s+=b[0];
		else if(press(s+b[1])==n) s+=b[1];
		else s+=b[2];	
	}
	return s; 
}
/*int main(){
	int n;
	cin>>n;
	guess_sequence(n);
}*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   if(t==s.size()){
      |      ~^~~~~~~~~~
combo.cpp:45:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   if(t==s.size()+1){
      |      ~^~~~~~~~~~~~
combo.cpp:48:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   if(t==s.size()+2){
      |      ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...