# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064766 | AlgorithmWarrior | Password (RMI18_password) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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 <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <stdlib.h>
#include <assert.h>
#include <queue>
#include <cstring>
using namespace std;
#define DEBUG 0
#define MAX_QUERIES 50000
#define MAX_N 5000
#define MAX_SIGMA 26
static string password;
static int n, s, numQueries;
static stringstream msg;
static void end(int success) {
cout << (success ? "SUCCESS! " : "ERROR: ") << msg.str() << endl;
exit(0);
}
int query(string q) {
}
class cmp
{
public:
bool operator()(string a,string b)
{
return a.size()>b.size();
}
};
string guess(int n, int s)
{
int cnt[300]={0};
char ch;
priority_queue<string,vector<string>,cmp>pq;
for(ch='a';ch<'a'+s;++ch)
{
int i;
string s="";
for(i=1,s=ch;s.size()<=n && query(s)==s.size();++i,s+=ch);
cnt[ch]=i-1;
s.pop_back();
if(s.size())
pq.push(s);
}
while(pq.size()>1)
{
string s1=pq.top(); pq.pop();
string s2=pq.top(); pq.pop();
int i,j=0;
int siz=s1.size();
int siz2=s2.size();
string rez="";
for(i=0;i<=siz;++i)
{
while(j<siz2 && query(rez+s2[j]+s1.substr(i,siz-i))==(rez+s2[j]+s1.substr(i,siz-i)).size())
rez+=s2[j++];
if(i<siz)
rez+=s1[i];
}
pq.push(rez);
}
return pq.top();
}