#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ull mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
double rngesus_d(double l, double r){
double wow = (double) ((ull) rng()) / ((ull)(0-1));
return wow * (r - l) + l;
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: container) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
int query(string q);
//int query(string q){
// cout << "? " << q << endl;
// int ans; cin >> ans;
// return ans;
//}
string go(int n, int u, int v){
if (u == v){
string wow(n, u + 'a');
int l = query(wow);
string ans = string(l, u + 'a');
return ans;
}
int mid = (u + v) >> 1;
string left = go(n, u, mid), right = go(n, mid+1, v);
if (left.size() == 0) return right;
if (right.size() == 0) return left;
reverse(ALL(right));
int sum = left.size() + right.size();
string ans;
for(int i = 0; i < (int) left.size(); ++i){
while(right.size()){
string cur = ans + string(1, right.back()) + left.substr(i);
int sigma = cur.size();
if (sigma > n) break;
cur += string(n - sigma, 'a');
if (query(cur) >= sigma) {
ans.push_back(right.back());
right.pop_back();
continue;
}
else break;
}
ans.push_back(left[i]);
}
reverse(ALL(right));
ans += right;
return ans;
}
string guess(int n, int s){
string ans = go(n, 0, s-1);
return ans;
}
//
//int main(void){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
//// cout << guess(5, 2) << "\n";
//
// return 0;
//}
# | 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... |