Submission #331232

#TimeUsernameProblemLanguageResultExecution timeMemory
331232PetiPassword (RMI18_password)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>

using namespace std;

string guess(int n, int s){
    vector<int> db(26, 0);
    for(int i = 0; i < s; i++){
        char c = (char)((int)'a' + i);
        string q;
        q.assign(n, c);
        db[i] = query(q);
    }

    string pass;
    pass.assign(db[0], 'a');
    for(int i = 1; i < s; i++){
        char c = (char)((int)('a' + i));
        for(int j = 0; j < db[i]; j++){
            int x = 0;
            while(1){
                string q = pass;
                q.insert(q.begin() + x, c);
                if(query(q) == (int)q.size()){
                    pass = q;
                    break;
                }
                x++;
            }
        }
    }

    return pass;
}

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:12:17: error: 'query' was not declared in this scope
   12 |         db[i] = query(q);
      |                 ^~~~~
password.cpp:24:20: error: 'query' was not declared in this scope
   24 |                 if(query(q) == (int)q.size()){
      |                    ^~~~~