Submission #756928

# Submission time Handle Problem Language Result Execution time Memory
756928 2023-06-12T11:26:07 Z ElyesChaabouni Password (RMI18_password) C++14
10 / 100
247 ms 444 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int query(string str);
string str, endChars, build, tmp, nEnd;
string guess(int n, int s) {
  endChars="";
 
  vector<int> freq(s);
  for (int i = 0; i < s; i++) {
    str="";
    for (int it = 0; it < n; it++) {
      str += (char)(i + 'a');
    }
    freq[i] = query(str);
  }
 
  for (int pos = n - 1; pos >= 0; pos--) {
    for (int i = 0; i < s; i++) {
      if (freq[i] > 0) {
        build="";
        for (int it = 0; it < freq[i]; it++) {
          build += (char)(i + 'a');
        }
        bool work = true;
 
        if ((int) build.size() + 1 + (int) endChars.size() <= n) {
          for (int j = 0; j < s; j++) {
            tmp="";
            tmp += build;
            tmp += (char)(j + 'a');
            tmp += endChars;
 
            if (query(tmp) == (int) tmp.length()) {
              work = false;
              break;
            }
          }
        }
 
        if (work) {
          freq[i] -= 1;
          nEnd="";
          nEnd += (char)(i + 'a');
          nEnd += endChars;
          endChars=nEnd;
          break;
        }
      }
    }
  }
  return endChars;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Guessed the password with 427 queries.
2 Correct 11 ms 208 KB Guessed the password with 1209 queries.
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Guessed the password with 135 queries.
2 Runtime error 4 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 247 ms 444 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Guessed the password with 427 queries.
2 Correct 11 ms 208 KB Guessed the password with 1209 queries.
3 Correct 2 ms 208 KB Guessed the password with 135 queries.
4 Runtime error 4 ms 208 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Guessed the password with 427 queries.
2 Correct 11 ms 208 KB Guessed the password with 1209 queries.
3 Correct 2 ms 208 KB Guessed the password with 135 queries.
4 Runtime error 4 ms 208 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -