Submission #256770

#TimeUsernameProblemLanguageResultExecution timeMemory
256770lani1akea콤보 (IOI18_combo)C++17
0 / 100
3086 ms384 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int N) {
  string p = "";
  vector<char> LET = {'A', 'B', 'X', 'Y'};
  int x, y, st = 0;
  y = press({"AB"});
  if (y >= 1) {
    st = y;
    p += (y == 2 ? "AB" : "A");
  } else {
    y = press({"BX"});
    if (y >= 1) {
      st = y;
      p += (y == 2 ? "BX" : "B");
    } else {
      y = press({"XY"});
      if (y >= 1) {
        st = y;
        p += (y == 2 ? "XY" : "X");
      } else {
        st = 1;
        p += "Y";
      }
    }
  }
  if (p[0] == 'A')
    LET.erase(LET.begin());
  else if (p[0] == 'B')
    LET.erase(LET.begin() + 1);
  else if (p[0] == 'X')
    LET.erase(LET.begin() + 2);
  else
    LET.erase(LET.begin() + 3);

  for (int i = st; i < N; ++i) {
    set<int>s;
    while(true) {
      random_shuffle(LET.begin(), LET.end());
      if (s.count(LET[0])) {
        continue;
      }
      y = press(p + LET[0] + LET[1] + LET[2]);
      if (y >= i + 1) {
        if (y == i + 1) {
          p += LET[0];
        } else if ( y == i + 2) {
          p += LET[0];
          p += LET[1];
          ++i;
        } else {
          p += LET[0];
          p += LET[1];
          p += LET[2];
          i += 2;
        }
        break;
      } else {
        s.insert(LET[0]);
        continue;
      }
    }
  }

  return p;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:7: warning: unused variable 'x' [-Wunused-variable]
    9 |   int x, y, st = 0;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...