Submission #1159681

#TimeUsernameProblemLanguageResultExecution timeMemory
1159681fryingducPassword (RMI18_password)C++20
0 / 100
14 ms460 KiB
#include "bits/stdc++.h"

using namespace std;

#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif

int query(string abc);

string calc(int l, int r, int len) {
  if (l == r) {
    string cur;
    for (int i = 0; i < len; ++i) {
      cur += char('a' + l);
    }
    int x = query(cur);
    cur = "";
    for (int i = 0; i < x; ++i) {
      cur += char('a' + l);
    }
    return cur;
  }
  int mid = (l + r) >> 1;
  string x = calc(l, mid, len);
  string y = calc(mid + 1, r, len);
  string res = "";
  int px = 0, py = 0;
  while (px < (int)x.size() and py < (int)y.size()) {
    string g = res + x[px];
    for (int i = py; i < (int)y.size(); ++i) {
      g += y[i];
    }
    int cur_g = query(g);
    if (cur_g > (int)res.size() + (int)y.size() - py) {
      res += x[px++];
    } else {
      res += y[py++];
    }
  }
  while (px < (int)x.size()) {
    res += x[px++];
  }
  while (py < (int)y.size()) {
    res += y[py++];
  }
  return res;
}

string guess(int _N, int _C) {
  return calc(0, _C - 1, _N);
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...