Submission #1007242

#TimeUsernameProblemLanguageResultExecution timeMemory
1007242andecaandeciCombo (IOI18_combo)C++17
0 / 100
0 ms344 KiB
#include <string>
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N)
{
  string ans;
  int val=press("AB"), find;
  if(val>0)
  {
    int cek=press("A");
    if(cek==0)
    {
      ans+="B";
      find=1;
    }
    else
    {
      ans+="A";
      find=0;
    }
  }
  else
  {
    int cek=press("X");
    if(cek==0)
    {
      ans+="Y";
      find=3;
    }
    else
    {
      ans+="X";
      find=2;
    }
  }
  if(find==0)
  {
    for(int i=2; i<N; i++)
    {
      string que=ans;
      que=que+ans+"YY";
      que=que+ans+"YX";
      que=que+ans+"YB";
      que=que+ans+"X";
      val=press(que);
      if(val==i)ans+="X";
      else if(val==i-1)ans+="B";
      else ans+="Y";  
    }
    string que;
    que=ans+"B";
    if(val==N)return que;
    que=ans+"X";
    if(val==N)return que;
    else return ans+"Y";
  }
  else if(find==1)
  {
    for(int i=2; i<N; i++)
    {
      string que=ans;
      que=que+ans+"YY";
      que=que+ans+"YX";
      que=que+ans+"YA";
      que=que+ans+"X";
      val=press(que);
      if(val==i)ans+="X";
      else if(val==i-1)ans+="A";
      else ans+="Y";  
    }
    string que;
    que=ans+"A";
    if(val==N)return que;
    que=ans+"X";
    if(val==N)return que;
    else return ans+"Y";
  }
  else if(find==2)
  {
    for(int i=2; i<N; i++)
    {
      string que=ans;
      que=que+ans+"YY";
      que=que+ans+"YB";
      que=que+ans+"YA";
      que=que+ans+"B";
      val=press(que);
      if(val==i)ans+="B";
      else if(val==i-1)ans+="A";
      else ans+="Y";  
    }
    string que;
    que=ans+"A";
    if(val==N)return que;
    que=ans+"B";
    if(val==N)return que;
    else return ans+"Y";
  }
  else if(find==3)
  {
    for(int i=2; i<N; i++)
    {
      string que=ans;
      que=que+ans+"XX";
      que=que+ans+"XB";
      que=que+ans+"XA";
      que=que+ans+"B";
      val=press(que);
      if(val==i)ans+="B";
      else if(val==i-1)ans+="A";
      else ans+="X";  
    }
    string que;
    que=ans+"A";
    if(val==N)return que;
    que=ans+"B";
    if(val==N)return que;
    else return ans+"X";
  }
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:10: warning: control reaches end of non-void function [-Wreturn-type]
    8 |   string ans;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...