#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
int ix[30], adx[10000], lst[10000];
char y[10000];
int query(string str);
string guess(int n, int s){
string ans = "";
int mx = 0, c = -1;
for (int i = 0; i < s; ++i){
string kek = "";
char ch = 'a';
ch += i;
for (int j = 1; j <= n; ++j){
kek += ch;
}
ix[i] = query(kek);
if (ix[i] > mx){
mx = ix[i];
c = i;
}
}
for (int j = 1; j <= mx; ++j){
char ch = 'a';
ch += c;
ans += ch;
}
ix[c] = 0;
vector<pair<int, int>> vv;
for (int i = 0; i < s; ++i){
vv.pb(mp(ix[i], i));
}
sort(vv.begin(), vv.end());
reverse(vv.begin(), vv.end());
for (int i = 0; i < s; ++i){
int jj = vv[i].s;
if (ix[jj] == 0){
continue;
}
char ch = 'a';
ch += jj;
string nans = "";
for (int j = 0; j < n; ++j){
if (j < (int)ans.size()){
y[j] = ans[j];
}
else{
y[j] = ch;
}
}
for (int j = (int)ans.size(); j >= 0; --j){
string q = "";
for (int k = 0; k < n; ++k){
if (k < j){
q += ans[k];
}
else{
q += ch;
}
}
int kek = query(q);
kek -= j;
adx[j] = kek - lst[j + 1];
lst[j] = lst[j + 1] + adx[j];
}
for (int j = 0; j <= (int)ans.size(); ++j){
while (adx[j] > 0){
nans += ch;
adx[j] -= 1;
}
if (j < (int)ans.size()){
nans += ans[j];
}
}
for (int j = 0; j < n; ++j){
lst[j] = 0, adx[j] = 0;
}
ans = nans;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Guessed the password with 135 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 299 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Guessed the password with 30 queries. |
2 |
Correct |
2 ms |
208 KB |
Guessed the password with 118 queries. |
3 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
320 KB |
Guessed the password with 8888 queries. |
2 |
Correct |
176 ms |
312 KB |
Guessed the password with 9811 queries. |
3 |
Correct |
443 ms |
336 KB |
Guessed the password with 23634 queries. |
4 |
Correct |
536 ms |
320 KB |
Guessed the password with 26019 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Guessed the password with 135 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 299 queries. |
3 |
Correct |
1 ms |
208 KB |
Guessed the password with 30 queries. |
4 |
Correct |
2 ms |
208 KB |
Guessed the password with 118 queries. |
5 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Guessed the password with 135 queries. |
2 |
Correct |
3 ms |
208 KB |
Guessed the password with 299 queries. |
3 |
Correct |
1 ms |
208 KB |
Guessed the password with 30 queries. |
4 |
Correct |
2 ms |
208 KB |
Guessed the password with 118 queries. |
5 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |