Submission #1365233

#TimeUsernameProblemLanguageResultExecution timeMemory
1365233khanhphucscratchPassword (RMI18_password)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

string combine(string s, string t)
{
    //Combine two string
    int j = 0;
    for(int i = 0; i < s.size(); i++){
        while(j < t.size()){
            string str = s; str.insert(str.begin() + i, t[j]);
            if(query(str) == str.size()){s = str; j++;}
        }
    }
    while(j < t.size()) s += t[j];
    return s;
}
string guess(int n, int s)
{
    vector<string> ans;
    for(int i = 0; i < s; i++){
        string cur;
        for(int j = 1; j <= n; j++) cur.push_back(i+'a');
        int num = query(cur);
        cur.clear();
        for(int j = 1; j <= num; j++) cur.push_back(i+'a');
        if(num > 0) ans.push_back(cur);
    }
    while(ans.size() > 1){
        sort(ans.begin(), ans.end(), [&](string &x, string &y){return x.size() > y.size();});
        string s = ans.back(); ans.pop_back();
        string t = ans.back(); ans.pop_back();
        ans.push_back(combine(s, t));
    }
    return ans[0];
}

Compilation message (stderr)

password.cpp: In function 'std::string combine(std::string, std::string)':
password.cpp:11:16: error: 'query' was not declared in this scope
   11 |             if(query(str) == str.size()){s = str; j++;}
      |                ^~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:23:19: error: 'query' was not declared in this scope
   23 |         int num = query(cur);
      |                   ^~~~~