Submission #1317976

#TimeUsernameProblemLanguageResultExecution timeMemory
131797612345678Combo (IOI18_combo)C++17
0 / 100
0 ms400 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

std::string guess_sequence(int N) {
  string res;
  vector<char> op={'A', 'B', 'X', 'Y'}, new_op; // new_op contains only the one not in first character
  char st;
  if (press("AB"))
  {
    if (press("A")) st='A';
    else st='B';
  }
  else
  {
    if (press("X")) st='X';
    else st='Y';
  }
  res=st;
  if (N==1) return res;
  for (int i=0; i<4; i++) if (st!=op[i]) new_op.push_back(op[i]);
  for (int i=1; i<N-1; i++)
  {
    string s=(res+new_op[0])+(res+new_op[1]+new_op[0])+(res+new_op[1]+new_op[1])+(res+new_op[1]+new_op[2]);
    int p=press(s);
    if (p==res.size()) res+=new_op[2];
    else if (p==res.size()+1) res+=new_op[0];
    else res+=new_op[1];
  }
  for (int i=0; i<2; i++) if (press(res+new_op[i])==N) return res+new_op[i]; 
}

Compilation message (stderr)

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