Submission #916867

#TimeUsernameProblemLanguageResultExecution timeMemory
916867_VIBECombo (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include "combo.h"
#include <string>
#include<bits/stdc++.h>
using namespace std;
 
string guess_sequence(int N);
 
int press(string p);
 
string guess_sequence(int N) {
 	
  	set<char> s={'A','X','B','Y'};
  	string ans;
  
  	//guesing the first character
  	// in three queries
  	
  	for(auto x:s){
      	string q;
      	q+=x;
      	if(press(q)==1){
          	s.erase(x);
          	ans=q;break;
        }
    }
  	//it means last character of set was our first element
  	if(s.size()==4){
      	ans=to_string(*s.rbegin());
      	s.erase(*s.rbegin());
    }
  
  	vector<char> v={s.begin(),s.end()};
  	// ans contains prefix of my actual string
  	
  	for(int i=1;i<N-1;i++){
      	
      	string q;
      	//query at ith index(0 based)
      	//lets say remaining three characters x,b,y
		// then i query for ans+xx+ans+xb+ans+xy+ans+y
      	//if result==i then b appears
      	// if result==i+2 then x appears
      	// if result==i+1 then y appears      
      
      	for(int j=0;j<3;j++) q+=ans+to_string(v[0])+to_string(v[j]);
      	
      	q+=ans+to_string(v[1]);
      	int res=press(q);
      	
      	if(res==i) ans+=v[2];
      	else if(res==i+2) ans+=v[0];
      	else ans+=v[1];
    
    }
  	
  	for(int i=0;i<2;i++){
      	string q=ans+to_string(v[i]);
      	if(press(q)==N) return q;
    }
  
  	return (ans+to_string(v[2]));
  	
  
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...