제출 #429635

#제출 시각아이디문제언어결과실행 시간메모리
429635TLP39콤보 (IOI18_combo)C++14
100 / 100
49 ms532 KiB
#include "combo.h"

char c[4]={'A','B','X','Y'};
int st;
std::string guess_sequence(int N) {
  std::string s = "";
  int temp;
  temp=press("AB");
  if(temp)
  {
    if(press("A")) {s+="A"; st=0;}
    else {s+="B"; st=1;}
  }
  else
  {
    if(press("X")) {s+="X"; st=2;}
    else {s+="Y"; st=3;}
  }
  if(N==1) return s;
  std:: string test="";

  for(int i=1;i<N-1;i++)
  {
    test.clear();
    test+=s;
    test.push_back(c[(st+1)%4]);
    test.push_back(c[(st+1)%4]);
    test+=s;
    test.push_back(c[(st+1)%4]);
    test.push_back(c[(st+2)%4]);
    test+=s;
    test.push_back(c[(st+1)%4]);
    test.push_back(c[(st+3)%4]);
    test+=s;
    test.push_back(c[(st+2)%4]);
    temp=press(test)-i;
    if(temp==2) s.push_back(c[(st+1)%4]);
    else if(temp==1) s.push_back(c[(st+2)%4]);
    else s.push_back(c[(st+3)%4]);
  }
  for(int i=1;i<=2;i++)
  {
    s.push_back(c[(st+i)%4]);
    if(press(s)==N) return s;
    s.pop_back();
  }
  s.push_back(c[(st+3)%4]);
  return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...