#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
string guess(int n, int s) {
vector<pair<int,string>>A;
rep(i, s) {
string p="";
rep(j, n) p+=char(i+'a');
int x=query(p);
while(p.size()>x) p.pop_back();
if(x) A.pb({x, p});
}
while(A.size()>1) {
sort(all(A));
reverse(all(A));
string a=A[A.size()-1].nd, b=A[A.size()-2].nd;
A.pop_back(); A.pop_back();
int l=0;
string ans="";
for(auto i : a) {
string x=ans;
x+=i;
for(int j=l; j<b.size(); ++j) x+=b[j];
while(query(x)<x.size()) {
ans+=b[l];
++l;
x=ans;
x+=i;
for(int j=l; j<b.size(); ++j) x+=b[j];
}
ans+=i;
}
A.pb({ans.size(), ans});
}
return A[0].nd;
}
Compilation message
password.cpp: In function 'std::string guess(int, int)':
password.cpp:14:9: error: 'query' was not declared in this scope
14 | int x=query(p);
| ^~~~~
password.cpp:15:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | while(p.size()>x) p.pop_back();
| ~~~~~~~~^~
password.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int j=l; j<b.size(); ++j) x+=b[j];
| ~^~~~~~~~~
password.cpp:29:10: error: 'query' was not declared in this scope
29 | while(query(x)<x.size()) {
| ^~~~~
password.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int j=l; j<b.size(); ++j) x+=b[j];
| ~^~~~~~~~~