Submission #853223

# Submission time Handle Problem Language Result Execution time Memory
853223 2023-09-23T16:38:57 Z allin27x Password (RMI18_password) C++17
30 / 100
100 ms 1472 KB
#include <bits/stdc++.h>
using namespace std;
 
int query(string str);
 
string guess(int n, int s){
    string res;
    vector<int> nc(s, 0);
    vector<int> to(s, -1);
    for (int i=0; i<s; i++) nc[i] = query(string(n,'a'+i));
    int last = -1;
    while (res.size()<n){
        string rev = res; reverse(rev.begin(), rev.end());
        int mx = -1; for (int i=0; i<s; i++) 
            if (nc[i] && (i==last || to[i] == last)) {mx = i; break;}
            
        for (int i=mx+1; i<s; i++){
            if (!nc[i] || (i!=last && to[i]!=last)) continue;
            if (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) {
                to[mx] = i;
                mx = i;
            } else {
                to[i] = mx;
            }
        }
        nc[mx] --; res += 'a' + mx;
        last = mx;
    }
    reverse(res.begin(), res.end());
    return res;
}
 

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:12:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     while (res.size()<n){
      |            ~~~~~~~~~~^~
password.cpp:19:70: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |             if (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 85 queries.
2 Correct 1 ms 344 KB Guessed the password with 153 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 47 queries.
2 Correct 1 ms 344 KB Guessed the password with 123 queries.
3 Correct 0 ms 344 KB Guessed the password with 17 queries.
4 Runtime error 1 ms 436 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1232 KB Guessed the password with 4745 queries.
2 Correct 49 ms 952 KB Guessed the password with 10455 queries.
3 Correct 57 ms 1472 KB Guessed the password with 11372 queries.
4 Correct 100 ms 980 KB Guessed the password with 20209 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 85 queries.
2 Correct 1 ms 344 KB Guessed the password with 153 queries.
3 Correct 1 ms 344 KB Guessed the password with 47 queries.
4 Correct 1 ms 344 KB Guessed the password with 123 queries.
5 Correct 0 ms 344 KB Guessed the password with 17 queries.
6 Runtime error 1 ms 436 KB Execution killed with signal 13
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 85 queries.
2 Correct 1 ms 344 KB Guessed the password with 153 queries.
3 Correct 1 ms 344 KB Guessed the password with 47 queries.
4 Correct 1 ms 344 KB Guessed the password with 123 queries.
5 Correct 0 ms 344 KB Guessed the password with 17 queries.
6 Runtime error 1 ms 436 KB Execution killed with signal 13
7 Halted 0 ms 0 KB -