Language: C++

#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
std::vector<int>a;
char s[maxn],ans[5];
int n,pos;
bool query(std::vector<int>a)
{
	printf("? ");
	for(int i=0;i<n-1;i++)
		writesp(a[i]);
	writeln(a[n-1]);
	fflush(stdout);
	scanf("%s",ans);
	return ans[0]=='R';
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a.push_back(i);
	if(query(a)){
		int l=1,r=n-1;
		while(l<r){
			int mid=(l+r)>>1;
			a.clear();
			for(int i=mid+1;i<=mid+n;i++)
				a.push_back(i);
			if(query(a))l=mid+1;
			else r=mid;
		}
		s[l]='R'; s[l+n]='B';
		pos=l;
	}
	else{
		int l=1,r=n-1;
		while(l<r){
			int mid=(l+r)>>1;
			a.clear();
			for(int i=mid+1;i<=mid+n;i++)
				a.push_back(i);
			if(!query(a))l=mid+1;
			else r=mid;
		}
		s[l]='B'; s[l+n]='R';
		pos=l;
	}
	a.clear();
	for(int i=pos+1;i<pos+n;i++)
		a.push_back(i);
	for(int i=1;i<=2*n;i++)
		if(i<pos||i>pos+n){
			a.push_back(i);
			if(query(a))s[i]='R';
			else s[i]='B';
			a.pop_back();
		}
	a.clear();
	for(int i=1;i<=2*n;i++)
		if(i<pos||i>pos+n)a.push_back(i);
	for(int i=pos+1;i<pos+n;i++){
		a.push_back(i);
		if(query(a))s[i]='R';
		else s[i]='B';
		a.pop_back();
	}
	printf("! %s\n",s+1);
}

Compiler output:
a.cc:27:6: error: 'vector' in namespace 'std' does not name a template type
   27 | std::vector<int>a;
      |      ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include<algorithm>
  +++ |+#include <vector>
    6 | #define ll long long
a.cc:30:17: error: 'vector' is not a member of 'std'
   30 | bool query(std::vector<int>a)
      |                 ^~~~~~
a.cc:30:17: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:30:24: error: expected primary-expression before 'int'
   30 | bool query(std::vector<int>a)
      |                        ^~~
a.cc: In function 'int main()':
a.cc:44:17: error: 'a' was not declared in this scope
   44 |                 a.push_back(i);
      |                 ^
a.cc:45:18: error: 'a' was not declared in this scope
   45 |         if(query(a)){
      |                  ^
a.cc:45:19: error: 'query' cannot be used as a function
   45 |         if(query(a)){
      |                   ^
a.cc:52:33: error: 'query' cannot be used as a function
   52 |                         if(query(a))l=mid+1;
      |                            ~~~~~^~~
a.cc:65:34: error: 'query' cannot be used as a function
   65 |                         if(!query(a))l=mid+1;
      |                             ~~~~~^~~
a.cc:71:9: error: 'a' was not declared in this scope
   71 |         a.clear();
      |         ^
a.cc:77:33: error: 'query' cannot be used as a function
   77 |                         if(query(a))s[i]='R';
      |                            ~~~~~^~~
a.cc:86:25: error: 'query' cannot be used as a function
   86 |                 if(query(a))s[i]='R';
      |                    ~~~~~^~~