# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
646323 | Matteo_Verz | Password (RMI18_password) | C++17 | 83 ms | 480 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.
#include <bits/stdc++.h>
#ifdef BLAT
#include "debug/debug.hpp"
#else
#define debug(x...)
#endif
using namespace std;
int query(string s);
string mergeStrings(string &a, string &b) {
string mergedSoFar, queryString;
while (a.size() || b.size()) {
if (!a.size()) {
mergedSoFar += b;
return mergedSoFar;
}
queryString = mergedSoFar + a[0] + b;
int len = query(queryString);
if (len == queryString.size()) {
mergedSoFar.push_back(a[0]);
a.erase(0, 1);
} else {
mergedSoFar.push_back(b[0]);
b.erase(0, 1);
}
}
return mergedSoFar;
}
struct Compare {
bool operator()(const string &a, const string &b) {
return a.size() > b.size();
}
};
string guess(int n, int s) {
string ask;
priority_queue <string, vector <string>, Compare> pq;
for (char ch = 'a'; ch - 'a' < s; ch++) {
ask.clear();
for (int i = 0; i < n; i++)
ask += ch;
int len = query(ask);
ask = "";
for (int i = 0; i < len; i++)
ask += ch;
pq.push(ask);
}
while (pq.size() > 1) {
string a = pq.top();
pq.pop();
string b = pq.top();
pq.pop();
string c = mergeStrings(a, b);
pq.push(c);
}
return pq.top();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |