Language: C++

#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#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 print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define pb push_back


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<long long> vll;

const int MAXN = 1e6 + 10;

void out(int i, int n){
	cout << "? ";
	rep(ii, i, i + n)
		cout << i << ' ';
	cout << endl;
}

void out(const vi & v) {
	cout << "? ";
	rep(i, 0, v.size())
		cout << v[i] << ' ';
	cout << endl;
}

int get() {
	int res1 = 0, res2 = 0;
	for(auto c : s) 
		if(c == 'R')
			res1++
		else res2++;
	if(res1 > res2)
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;
    int n;
    cin >> n;

    string res(n, ' ');

    out(1, n);
    string base;
    cin >> base;
    int lo = 2, hi = n + 1, mid;
    while(lo + 1 < hi){
    	mid = lo + (hi - lo) / 2;
    	out(mid, n);
    	string cur;
    	cin >> cur;
    	if(cur == base)
    		lo = mid;
    	else 
    		hi = mid;
    }
    lo = hi;

    vi a(n);
    iota(a.begin(), a.end(), lo);
    rep(i, 1, 2 * n + 1) {
    	if(lo <= i && i < lo + n - 1) continue;
    	a.back() = i;
    	out(a);
    	string cur;
    	cin >> cur;
    	res[i - 1] = cur[0];
    }

    a.clear();
    int cur1 = 0, cur2 = 0;
    rep(i, 1, 2 * n + 1) {
    	if(lo <= i && i < lo + n - 1) continue;
    	if(res[i - 1] == 'R') {
    		cur1++;
    		if(cur1 <= n / 2)
		    	a.pb(i);
	    }
    	if(res[i - 1] == 'B') {
    		cur2++;
    		if(cur2 <= n / 2)
		    	a.pb(i);
	    }
    }
    a.pb(0);
    rep(i, lo, lo + n - 1) {
    	a.back() = i;
    	out(a);
    	string cur;
    	cin >> cur;
    	res[i - 1] = cur[0];
    }

    cout << "! " << res << endl;
    return 0;
}













Compiler output:
a.cc: In function 'int get()':
a.cc:81:22: error: 's' was not declared in this scope
   81 |         for(auto c : s)
      |                      ^
a.cc:83:31: error: expected ';' before 'else'
   83 |                         res1++
      |                               ^
      |                               ;
   84 |                 else res2++;
      |                 ~~~~           
a.cc:86:1: error: expected primary-expression before '}' token
   86 | }
      | ^
a.cc:86:1: warning: no return statement in function returning non-void [-Wreturn-type]