Submission #859807

# Submission time Handle Problem Language Result Execution time Memory
859807 2023-10-10T17:30:09 Z Andrei_Calota Password (RMI18_password) C++17
0 / 100
83 ms 508 KB
#include <iostream>

using namespace std;
const int N_MAX = 5e3;
const int SIGMA_MAX = 26;

/**int query (string candidate) {
   cout << candidate << "\n";
   int ret; cin >> ret;
   return ret;
}**/

int query (string str);

string getCopy (int letter, int f) {
    string ret = "";
    for (int i = 0; i < f; i ++)
       ret = ret + char (letter + 'a');
    return ret;
}


int freq[SIGMA_MAX];
string guess (int n, int s) {
    int N = n, SIGMA = s;
    string aux;
    for (int letter = 0; letter < SIGMA; letter ++) {
       aux = getCopy (letter, N);
       freq[letter] = query (aux);
    }

    string done = "";
    for (int pos = N - 1; pos >= 0; pos --) {
       int left = 0, right = 1;
       while (right < SIGMA) {
          if (freq[left] == 0) {
            left ++;
            right = max (right, left + 1);
            continue;
          }
          if (freq[right] == 0) {
            right ++;
            continue;
          }

          aux = getCopy (left, freq[left]);
          aux = aux + char (right + 'a');
          aux = aux + done;
          if (query (aux) == freq[left])
            right ++;
          else
            left ++, right ++;
       }
       done = char (left + 'a') + done;
       freq[left] --;
    }

    return done;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Returned early from guess() after 33 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 508 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -