#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long, long> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FR(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define RF(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
//string ori;
//int query(str s) {
// int cur = 0;
// for (int i = 0; i < ori.length() && cur < s.length(); i++) {
// if (ori[i] == s[cur]) {
// cur++;
// }
// }
// return cur;
//}
string guess(int n, int s) {
vector<str> vec(s);
FR(i, s) {
str base = "";
FR(j, n) {
base += (char)(i + 'a');
}
vec[i] = base.substr(0, query(base));
}
sort(vec.begin(), vec.end(), [ ](const string& lhs, const string& rhs){
return (lhs.length() < rhs.length());
});
string cur = "";
RF(i, s) {
string next = vec[i];
FR(j, vec[i].length()) {
int low = 0;
int high = cur.length();
while (low < high) {
int mid = (low + high + 1)/2;
string cpy = vec[i];
cpy.insert(j, cur.substr(0, mid));
if (query(cpy) == cpy.length()) {
low = mid;
}
else {
high = mid-1;
}
}
vec[i].insert(j, cur.substr(0, low));
cur = cur.substr(low);
j += low;
}
vec[i] += cur;
cur = vec[i];
}
return cur;
}
//int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// cin >> ori;
// cout << guess(ori.size(), 26) << endl;
//}
Compilation message
password.cpp: In function 'std::string guess(int, int)':
password.cpp:39:33: error: 'query' was not declared in this scope
39 | vec[i] = base.substr(0, query(base));
| ^~~~~
password.cpp:17:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
| ^
password.cpp:18:17: note: in expansion of macro 'FOR'
18 | #define FR(i,a) FOR(i,0,a)
| ^~~
password.cpp:47:9: note: in expansion of macro 'FR'
47 | FR(j, vec[i].length()) {
| ^~
password.cpp:54:21: error: 'query' was not declared in this scope
54 | if (query(cpy) == cpy.length()) {
| ^~~~~