Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[300];
ll S[300];

int main()
{
    ll N;
    cin >> N;
    memset(A, 0, sizeof(A));
    memset(S, 0, sizeof(S));

    string prev;
    cout << "? ";
    REP(i, N)
    {
        cout << i + 1;
        if (i < N - 1)
            cout << " ";
    }
    cout << endl;

    cin >> preb;

    int index = 1;
    int next = 0;

    bool flag = false;
    bool flag2 = false;
    while (true)
    {
        bool end = true;
        REP(i, 2 * N)
        {
            if (A[i] == 0)
                end = false;
        }

        if (end)
        {
            cout << "! ";
            ;
            REP(i, 2 * N)
            {
                if (A[i] == 1)
                    cout << "R";
                else if (A[i] == 2)
                    cout << "B";
            }
            cout << endl;
            break;
        }

        if (!flag)
        {
            cout << "? ";
            REP(i, N)
            {
                cout << i + 1 + index;
                if (i < N - 1)
                    cout << " ";
            }
            cout << endl;

            string s;
            cin >> s;
            if (s == prev)
            {
                //  S[index - 1] = index - 1 + N;
                index++;
                continue;
            }

            //! 変わった
            if (prev == "Red")
            {
                A[index - 1] = 1;
                A[index - 1 + N] = 2;
            }
            else
            {
                A[index - 1] = 2;
                A[index - 1 + N] = 1;
            }
            flag = true;
            continue;
        }

        if (!flag2)
        {
            //! 1個確定してる
            //! index-1 はR or B
            while (next >= index - 1 && next <= index + N - 1)
                next++;

            if (next >= 2 * N)
            {
                flag2 = true;
                continue;
            }
            cout << "? " << next + 1 << " ";
            REP(i, N - 1)
            {
                cout << index << " ";
            }
            cout << endl;

            string an;
            cin >> an;
            if (an == prev)
            {
                A[next] = A[index - 1];
            }
            else
            {
                A[next] = A[index - 1 + N];
            }
            next++;
        }

        //! N個確定
        vector<ll> b, r;
        REP(i, 2 * N)
        {
            if (A[i] == 1 && r.size() < N / 2)
                r.push_back(i + 1);
            else if (A[i] == 2 && b.size() / 2)
                b.push_back(i + 1);
        }

        ll num = 0;
        REP(i, 2 * N)
        {
            if (A[i] == 0)
            {
                num = i + 1;
                break;
            }
        }

        cout << "? " << num << " ";
        REP(i, N / 2)
        {
            cout << r[i] << " " << b[i] << " ";
        }
        cout << endl;
        string ans2;
        cin >> ans2;
        if (ans2 == "Red")
            A[num - 1] = 1;
        else
            A[num - 1] = 2;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:12: error: 'preb' was not declared in this scope; did you mean 'prev'?
   34 |     cin >> preb;
      |            ^~~~
      |            prev