#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
int query(string str);
string guess(int n, int s) {
// subtask one
int exists[26] = { 0 };
vector<ii> gthan(s, {0, 0});
for (int i = 0; i < s; i++) gthan[i].second = i;
char q[3] = "\0\0";
for (int i = 0 ; i < s; i++) {
q[0] = i + 'a';
exists[i] = query(string(q));
}
for (int i = 0 ; i < s; i++) for (int j = i+1; j < s; j++) {
if ((!exists[i]) || (!exists[j])) continue;
q[0] = i + 'a';
q[1] = j + 'a';
int result = query(string(q));
gthan[j].first += (result-1);
gthan[i].first += (2-result);
}
sort(gthan.begin(), gthan.end());
string ans;
for (auto q : gthan) {
if (exists[q.second]) ans.push_back((char)(q.second + 'a'));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 121 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 277 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Returned early from guess() after 4 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Returned early from guess() after 79 queries. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 121 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 277 queries. |
3 |
Incorrect |
0 ms |
208 KB |
Returned early from guess() after 4 queries. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 121 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 277 queries. |
3 |
Incorrect |
0 ms |
208 KB |
Returned early from guess() after 4 queries. |
4 |
Halted |
0 ms |
0 KB |
- |