#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "C:\GCC\debug.h"
#else
#define debug(...) void(42)
#endif
int query(string str);
/*
int query(string str) {
cout << str << endl;
int x;
cin >> x;
return x;
}
*/
string guess(int n, int s) {
string endChars;
vector<int> freq(s);
for (int i = 0; i < s; i++) {
string str;
for (int it = 0; it < n; it++) {
str += (i + 'a');
}
freq[i] = query(str);
if (freq[i] == n) {
return str;
}
}
string res;
for (int i = 0; i < s; i++) {
for (int j = 0; j < freq[i]; j++) {
res += (i + 'a');
}
}
auto Build = [&](char i, char j) {
string str;
str += i;
str += j;
return str;
};
sort(res.begin(), res.end(), [&](char i, char j) {
if (i == j) {
return false;
}
if (query(Build(i, j)) == 2) {
return true;
}
return false;
});
return res;
}
/*
int main() {
guess(5, 5);
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 85 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 145 queries. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
208 KB |
Returned early from guess() after 553 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
284 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 85 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 145 queries. |
3 |
Incorrect |
5 ms |
208 KB |
Returned early from guess() after 553 queries. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 85 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 145 queries. |
3 |
Incorrect |
5 ms |
208 KB |
Returned early from guess() after 553 queries. |
4 |
Halted |
0 ms |
0 KB |
- |