#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define rep(x,s,e) for (auto x=s;x!=e;x++)
#define sz(x) (int) (x).size()
#define all(x) (x).begin(),(x).end()
#define si pair<int,string>
priority_queue<si,vector<si>,greater<si> > pq;
int query(string q);
string merge(string i,string j){
string res=i;
int idx=0;
for (auto &it:j){
while (true){
res.insert(idx,1,it);
if (query(res)==sz(res)){
break;
}
res.erase(res.begin()+idx);
idx++;
}
}
return res;
}
string guess(int n,int s){
rep(x,0,s){
string st;
rep(y,0,n) st+=(char)('a'+x);
int temp=query(st);
st="";
rep(y,0,temp) st+=(char)('a'+x);
pq.push(si(temp,st));
}
while (sz(pq)>1){
string t1=pq.top().se;pq.pop();
string t2=pq.top().se;pq.pop();
string ss=merge(t1,t2);
pq.push(si(sz(ss),ss));
}
return pq.top().se;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 79 queries. |
2 |
Correct |
2 ms |
256 KB |
Guessed the password with 157 queries. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 73 queries. |
2 |
Correct |
1 ms |
256 KB |
Guessed the password with 146 queries. |
3 |
Correct |
1 ms |
256 KB |
Guessed the password with 91 queries. |
4 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 79 queries. |
2 |
Correct |
2 ms |
256 KB |
Guessed the password with 157 queries. |
3 |
Correct |
1 ms |
256 KB |
Guessed the password with 73 queries. |
4 |
Correct |
1 ms |
256 KB |
Guessed the password with 146 queries. |
5 |
Correct |
1 ms |
256 KB |
Guessed the password with 91 queries. |
6 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Guessed the password with 79 queries. |
2 |
Correct |
2 ms |
256 KB |
Guessed the password with 157 queries. |
3 |
Correct |
1 ms |
256 KB |
Guessed the password with 73 queries. |
4 |
Correct |
1 ms |
256 KB |
Guessed the password with 146 queries. |
5 |
Correct |
1 ms |
256 KB |
Guessed the password with 91 queries. |
6 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |