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 <stdio.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
int ix[30], adx[10000], lst[10000];
char y[10000];
int query(string str);
string guess(int n, int s){
string ans = "";
int mx = 0, c = -1;
for (int i = 0; i < s; ++i){
string kek = "";
char ch = 'a';
ch += i;
for (int j = 1; j <= n; ++j){
kek += ch;
}
ix[i] = query(kek);
if (ix[i] > mx){
mx = ix[i];
c = i;
}
}
for (int j = 1; j <= mx; ++j){
char ch = 'a';
ch += c;
ans += ch;
}
ix[c] = 0;
vector<pair<int, int>> vv;
for (int i = 0; i < s; ++i){
vv.pb(mp(ix[i], i));
}
sort(vv.begin(), vv.end());
reverse(vv.begin(), vv.end());
for (int i = 0; i < s; ++i){
int jj = vv[i].s;
if (ix[jj] == 0){
continue;
}
char ch = 'a';
ch += jj;
string nans = "";
for (int j = 0; j < n; ++j){
if (j < (int)ans.size()){
y[j] = ans[j];
}
else{
y[j] = ch;
}
}
for (int j = (int)ans.size(); j >= 0; --j){
string q = "";
for (int k = 0; k < n; ++k){
if (k < j){
q += ans[k];
}
else{
q += ch;
}
}
int kek = query(q);
kek -= j;
adx[j] = kek - lst[j + 1];
lst[j] = lst[j + 1] + adx[j];
}
for (int j = 0; j <= (int)ans.size(); ++j){
while (adx[j] > 0){
nans += ch;
adx[j] -= 1;
}
if (j < (int)ans.size()){
nans += ans[j];
}
}
for (int j = 0; j < n; ++j){
lst[j] = 0, adx[j] = 0;
}
ans = nans;
}
return ans;
}
# | 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... |