Submission #631471

#TimeUsernameProblemLanguageResultExecution timeMemory
631471StavabCombo (IOI18_combo)C++14
5 / 100
1 ms220 KiB
#include <combo.h>

using namespace std;

string guess_sequence(int n)
{
    string s;
    char c[3];
    
    if(press("X"))
    {
        s.push_back('X');
        
        c[0] = 'A';
        c[1] = 'B';
        c[2] = 'Y';
    }
    else if(press("A"))
    {
        s.push_back('A');
        
        c[0] = 'X';
        c[1] = 'B';
        c[2] = 'Y';
    }
    else if(press("B"))
    {
        s.push_back('B');
        
        c[0] = 'X';
        c[1] = 'A';
        c[2] = 'Y';
    }
    else
    {
        s.push_back('Y');
        
        c[0] = 'X';
        c[1] = 'A';
        c[2] = 'B';
    }
    
    for(int i = 2; i < n - 1; i++)
    {
        string newS = "";
        
        string s1 = s;
        s1.push_back(c[0]);
        for(int i = 0; i < 3; i++)
        {
            string s2 = s1;
            s2.push_back(c[i]);
            
            newS += s2;
        }
        
        s1.pop_back();
        s1.push_back(c[1]);
        
        newS += s1;
        
        int ans = press(newS);
        
        if(ans == i + 2)
            s.push_back(c[0]);
        else if(ans == i + 1)
            s.push_back(c[1]);
        else
            s.push_back(c[2]);
    }
  	s.push_back(c[0]);
  	if(press(s) != n - 1)
    {
		s.pop_back();
      	s.push_back(c[1]);
      	if(press(s) != n - 1)
        {
         	s.pop_back();
          	s.push_back(c[2]);
        }
    }
  	s.push_back(c[0]);
  	if(press(s) != n)
    {
		s.pop_back();
      	s.push_back(c[1]);
      	if(press(s) != n)
        {
         	s.pop_back();
          	s.push_back(c[2]);
        }
    }
    
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...