// Sample grader for contestants' use.
//
// Usage: place your input data in the file password.in in the format
//
// line 1: N S
// line 2: hidden_password
//
// Then compile this grader together with your implementation.
// Run the binary to see your guessing strategy at work!
// Set DEBUG to 1 to print all queries.
#include <bits/stdc++.h>
using namespace std;
int query(string q);
#define fi first
#define se second
#define pb push_back
#define mp make_pair
string join(string a,string b){
int la=a.length(),lb=b.length();
string q=b+a;
string ans;
int done=0;
for(int i=0;i<la;i++){
int ret=query(q);
int newb=ret-la-done;
for(int j=done;j<done+newb;j++){
ans.pb(b[j]);
}
ans.pb(a[i]);
q=ans;
for(int j=done+newb;j<lb;j++)q.pb(b[j]);
for(int j=i+1;j<la;j++)q.pb(a[j]);
done+=newb;
if(done==lb)break;
}
for(int j=done;j<lb;j++)ans.pb(b[j]);
return ans;
}
string guess(int n, int s){
priority_queue<pair<int,string>,vector<pair<int,string> >,greater<pair<int,string> > > pq;
int occ[26];
for(int i=0;i<s;i++){
string q="";
for(int j=0;j<n;j++)q.pb(i+'a');
occ[i]=query(q);
q="";
for(int j=0;j<occ[i];j++)q.pb(i+'a');
if(occ[i]>0)pq.push(mp(occ[i],q));
}
while((int)pq.size()>1){
pair<int,string> cur1=pq.top();pq.pop();
pair<int,string> cur2=pq.top();pq.pop();
pq.push(mp(cur1.fi+cur2.fi,join(cur1.se,cur2.se)));
}
return pq.top().se;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Token "g |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Token "bbbbbbaabbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaa" doesn't correspond to pattern "[a-b]{1,50}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
384 KB |
Token "da |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Token "g |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Token "g |
2 |
Halted |
0 ms |
0 KB |
- |