Language: C++

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

// long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

const int MAXN = 1e6+10;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
}

int cal(const string & s1, const string & s2) {
    int n1=s1.size(),n2=s2.size();
    vvi dp(n1+1,vi(n2+1));
    rep(i,1,n1+1) dp[i][0]=i;
    rep(j,1,n2+1) dp[0][j]=j;
    rep(i,1,n1+1) rep(j,1,n2+1) {
        dp[i][j]=min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(s1[i-1]!=s2[j-1])});
    }
    return dp[n1][n2];
}

string ss;
int tot=0;
int get(const string & s) {
    cout<<"? "<<s<<endl;

    int tmp;
    cin>>tmp;
    // tmp=cal(s,ss);
    // tot++;
    // print(tot,tmp);

    return tmp;
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    string cs="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    // rep(i,0,26) cs+='a'+i;
    // rep(i,0,26) cs+='A'+i;
    // rep(i,0,10) cs+='0'+i;

    int n=128;

    // n=4;
    // ss=string(n,'0');
    // rep(i,0,7) frand(ss,cs);
    // print(ss);

    string tmp1(n,'a');
    int ans1=get(tmp1);
    string tmp2="a";
    int ans2=get(tmp2);
    n=


    set<pair<int,string>> cur;
    for(auto c:cs) {
        int tmp=get(string(n,c));
        if(n-tmp) cur.insert({n-tmp,string(n-tmp,c)});
    }

    n=0;
    for(auto & p:cur) n+=p.first;
        print(n);

    print(cur);

    while(cur.size()>1) {
        auto s1=cur.begin()->second;
        cur.erase(cur.begin());
        auto s2=cur.begin()->second;
        cur.erase(cur.begin());

        if(s1.size()>s2.size()) swap(s1,s2);
        print("combine", s1,s2);

        // int d;
        // d=get(s1+s2);

        int i=0,tmpd;
        while(i<s1.size()&&s2.size()) {
            string tmp=s1.substr(0,i)+s2[0]+s1.substr(i,s1.size()-i);
            tmpd=get(tmp);
            if(tmpd==n-tmp.size()) {
                s1=s1.substr(0,i)+s2[0]+s1.substr(i,s1.size()-i);
                s2=s2.substr(1,s2.size()-1);
                // d=tmpd;
            }
            i++;
        }
        s1+=s2;

        // string sv;
        // for(auto c:ss) if(find(all(s1),c)!=s1.end()) sv+=c;
        // // print(s1,sv,get(sv));
        // assert(sv==s1);

        cur.insert({s1.size(),s1});
    }
    string res=cur.begin()->second;
    cout<<"! "<<res<<endl;
    // assert(ss==res);



    return 0;
}




















Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:104:27: error: expected primary-expression before 'cur'
  104 |     set<pair<int,string>> cur;
      |                           ^~~
a.cc:107:19: error: 'cur' was not declared in this scope
  107 |         if(n-tmp) cur.insert({n-tmp,string(n-tmp,c)});
      |                   ^~~
a.cc:111:18: error: 'cur' was not declared in this scope
  111 |     for(auto & p:cur) n+=p.first;
      |                  ^~~
a.cc:116:11: error: 'cur' was not declared in this scope
  116 |     while(cur.size()>1) {
      |           ^~~
a.cc:148:16: error: 'cur' was not declared in this scope
  148 |     string res=cur.begin()->second;
      |                ^~~