Submission #251366

#TimeUsernameProblemLanguageResultExecution timeMemory
251366jamielimPassword (RMI18_password)C++14
0 / 100
23 ms384 KiB
// 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...