제출 #1311457

#제출 시각아이디문제언어결과실행 시간메모리
1311457nataliaa콤보 (IOI18_combo)C++20
100 / 100
11 ms640 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
  int x;
  string s;
  char c='C';
   x = press("AB");
  if(x>=1){
    x = press("B");
    if(x==1) c='B';
    else c = 'A';
  }
  else {
    x = press("X");
    if(x==1) c='X';
    else c = 'Y';
  }
  s+=c;
  if(N==1)return s;
  string s1, s2, s3, s4;
  char c1, c2, c3, c4;
  if(c=='A'){
    s1 = "B"; s2 = "XX";s3 = "XY";s4 = "XB";
    c1 ='Y';c2 = 'B';c3 = 'X';
  }
  if(c=='B'){
    s1 = "A"; s2 = "XX";s3 = "XY";s4 = "XA";
    c1 ='Y';c2 = 'A';c3 = 'X';
  }
  if(c=='X'){
    s1 = "B"; s2 = "AA";s3 = "AY";s4 = "AB";
    c1 ='Y';c2 = 'B';c3 = 'A';
  }
  if(c=='Y'){
    s1 = "B"; s2 = "XX";s3 = "XA";s4 = "XB";
    c1 ='A';c2 = 'B';c3 = 'X';
  }
  for(int i = 1; i < N-1; i++){
    string st[4] = {s, s, s, s};
    st[0]+=s1;
    st[1]+=s2;
    st[2]+=s3;
    st[3]+=s4;
    x = press(st[0]+st[1]+st[2]+st[3]);
    if(x==i) s+=c1;
    else if(x==i+1) s+=c2;
    else if(x==i+2) s+=c3;
    else s+='A';
  }
  if(c=='A'){
    x = press(s+'B');
    if(x==N) s+='B';
    else {
        x = press(s+'X');
        if(x==N) s+='X';
        else s+='Y';
    }
  }
  if(c=='B'){
    x = press(s+'A');
    if(x==N) s+='A';
    else {
        x = press(s+'X');
        if(x==N) s+='X';
        else s+='Y';
    }
  }
  if(c=='X'){
    x = press(s+'B');
    if(x==N) s+='B';
    else {
        x = press(s+'A');
        if(x==N) s+='A';
        else s+='Y';
    }
  }
  if(c=='Y'){
    x = press(s+'B');
    if(x==N) s+='B';
    else {
        x = press(s+'X');
        if(x==N) s+='X';
        else s+='A';
    }
  }
  return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...