Problem:
 Score: 800 points    Problem Statement  This is an interactive task.  We have 2N balls arranged in a row, numbered 1, 2, 3, ..., 2N from left to right, where N is an odd number. Among them, there are N red balls and N blue balls.  While blindfolded, you are challenged to guess the color of every ball correctly, by asking at most 210 questions of the following form:   You choose any N of the 2N balls and ask whether there are more red balls than blue balls or not among those N balls.   Now, let us begin.      Constraints   1 \leq N \leq 99  N is an odd number.        Input and Output  First, receive the number of balls of each color, N , from Standard Input:  N   Then, ask questions until you find out the color of every ball.
A question should be printed to Standard Output in the following format:  ? A_1  A_2  A_3  ...  A_N   This means that you are asking about the N balls A_1, A_2, A_3, ..., A_N , where 1 \leq A_i \leq 2N and A_i \neq A_j (i \neq j) must hold.  The response T to this question will be given from Standard Input in the following format:  T   Here T is one of the following strings:   Red : Among the N balls chosen, there are more red balls than blue balls.  Blue : Among the N balls chosen, there are more blue balls than red balls.  -1 : You printed an invalid question (including the case you asked more than 210 questions), or something else that was invalid.   If the judge returns -1 , your submission is already judged as incorrect. The program should immediately quit in this case.  When you find out the color of every ball, print your guess to Standard Output in the following format:  ! c_1 c_2 c_3 ... c_{2N}   Here c_i should be the character representing the color of Ball i ; use R for red and B for blue.      Notice   Flush Standard Output each time you print something. Failure to do so may result in TLE .  Immediately terminate your program after printing your guess (or receiving the -1 response). Otherwise, the verdict will be indeterminate.  If your program prints something invalid, the verdict will be indeterminate.        Sample Input and Output    Input  Output    3      ? 1 2 3    Red      ? 2 4 6    Blue      ! RRBBRB    In this sample, N = 3 , and the colors of Ball 1, 2, 3, 4, 5, 6 are red, red, blue, blue, red, blue, respectively.   In the first question, there are two red balls and one blue ball among the balls 1, 2, 3 , so the judge returns Red .  In the second question, there are one red ball and two blue balls among the balls 2, 4, 6 , so the judge returns Blue .

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))


def ask(la):
    out = "?"
    for a in la:
        out += " " + str(a+1)
    print(out, flush=True)
    c = input()
    return c

def answer(ans):
    out = "! "
    for a in ans:
        if a == 'Red':
            out += "R"
        else:
            out += "B"
    print(out, flush=True)
    return

def find_same(n):
    ids = [i for i in range(2*n)]
    l = 0
    r = n
    bc = ask(ids[:n])
    while (r-l > 1):
        mid = (l+r)//2
        c = ask(ids[mid:mid+n])
        if c == bc:
            l = mid
        else:
            r = mid
    return ids[l+1:l+n]

def main():
    n = ri()
    ids = [i for i in range(2*n)]
    ans = [None for _ in range(2*n)]
    if n == 1:
        c = ask([0])
        if c == 'Red':
            ans[0] = 'Red'
            ans[1] = 'Blue'
        else:
            ans[0] = 'Blue'
            ans[1] = 'Red'
        answer(ans)
        return
        
    
    
    
    
    
    
    
    
    
    
    
    same = find_same(n)
    
    for i in range(same[0]):
        if ans[i] is not None:
            continue
        ids = [i] + same
        c = ask(ids)
        ans[i] = c
    for i in range(same[-1]+1, 2*n):
        if ans[i] is not None:
            continue
        ids = same + [i]
        c = ask(ids)
        ans[i] = c
    
    half = (n-1) // 2
    cr = 0
    cb = 0
    same2 = []
    for i in range(2*n):
        if ans[i] is None:
            continue
        if ans[i] == "Red":
            if cr < half:
                same2.append(i)
                cr += 1
        else:
            if cb < half:
                same2.append(i)
                cb += 1
    for i in range(same[0], same[-1]+1):
        ids = [i] + same2 
        c = ask(ids)
        ans[i] = c
    answer(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    def qFromA(a):
        print("?", *list(range(a, a + n)))

    n = int(input())
    ans = [-1] * (2 * n + 1)

    
    qFromA(1)
    if input() == "Red":
        r, b = 1, 1 + n
    else:
        r, b = n + 1, 1
    while abs(r - b) > 1:
        m = (r + b) // 2
        qFromA(m)
        if input() == "Red":
            r = m
        else:
            b = m
    
    
    if r < b:
        ans[r], ans[r + n] = 1, 0
    else:
        ans[b], ans[b + n] = 0, 1
    
    min_rb = min(r, b)
    even0 = list(range(min_rb + 1, min_rb + n))
    even1 = list(range(1, min_rb)) + list(range(min_rb + n + 1, 2 * n + 1))
    
    

    
    for x in even0:
        print("?", x, *even1)
        ans[x] = input() == "Red"
    for x in range(1, 2 * n + 1):
        if ans[x] != -1: continue
        print("?", x, *even0)
        ans[x] = input() == "Red"
    
    print("! ", end="")
    for c in ans[1:]:
        if c:
            print("R", end="")
        else:
            print("B", end="")
    print()

main()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

prod=True
N=5
ANS="BRRBBRBRBR"

def ask(A): 
    print("? {}".format(' '.join(map(str,A))))
    sys.stdout.flush()
    if(prod): return input()
    else:
        cnt=0
        for a in A:
            cnt+=ANS[a-1]=='R'
        return "Red" if(cnt>(N-cnt)) else "Blue"

def resolve():        
    n=int(input()) if(prod) else N

    
    l=1; r=n+1
    lcol=ask(range(1,1+n))
    rcol="Red" if(lcol=="Blue") else "Blue"
    while(r-l>1):
        h=(l+r)//2
        hcol=ask(range(h,h+n))
        if(lcol==hcol): l=h
        else: r=h

    res=[None]*(2*n+1) 
    idx=l
    res[idx]=lcol[0]
    res[idx+n]=rcol[0]

    for i in range(1,idx):
        A=[i]+list(range(idx+1,idx+n))
        res[i]=ask(A)[0]
    for i in range(idx+n+1,2*n+1):
        A=list(range(idx+1,idx+n))+[i]
        res[i]=ask(A)[0]
    for i in range(idx+1,idx+n):
        A=list(range(1,idx))+[i]+list(range(idx+n+1,2*n+1))
        res[i]=ask(A)[0]
    print("! {}".format(''.join(res[1:])))
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

prod=True
N=5
ANS="BRRBBRBRBR"

def ask(A): 
    print("? {}".format(' '.join(map(str,A))))
    sys.stdout.flush()
    if(prod): return input()
    else:
        cnt=0
        for a in A:
            cnt+=ANS[a-1]=='R'
        return "Red" if(cnt>(N-cnt)) else "Blue"

def resolve():
    def make_list(i):
        assert 1<=i<=n+1
        return list(range(i,i+n))
        
    n=int(input()) if(prod) else N

    
    l=1; r=n+1
    lcol=ask(make_list(1))
    rcol="Red" if(lcol=="Blue") else "Blue"
    while(r-l>1):
        h=(l+r)//2
        hcol=ask(make_list(h))
        if(lcol==hcol): l=h
        else: r=h

    res=[None]*(2*n+1) 
    idx=l
    res[idx]=lcol[0]
    res[idx+n]=rcol[0]

    for i in range(1,idx):
        A=[i]+list(range(idx+1,idx+n))
        res[i]=ask(A)[0]
    for i in range(idx+n+1,2*n+1):
        A=list(range(idx+1,idx+n))+[i]
        res[i]=ask(A)[0]
    for i in range(idx+1,idx+n):
        A=list(range(1,idx))+[i]+list(range(idx+n+1,2*n+1))
        res[i]=ask(A)[0]
    print("! {}".format(''.join(res[1:])))
resolve()

Solution (Python):
def solve(n):
    aaa = list(range(1, 2 * n + 1))
    print('?', *aaa[:n])
    l_res = input()
    l = 1
    r = n
    while l < r:
        m = (l + r) // 2
        print('?', *aaa[m:m + n])
        res = input()
        if res == '-1':
            exit()
        if l_res == res:
            l = m + 1
        else:
            r = m

    same_rb1 = aaa[l:l + n - 1]
    same_rb2 = aaa[:l - 1] + aaa[l + n:]
    ans = [''] * (2 * n)
    ans[l - 1] = l_res[0]
    ans[l + n - 1] = 'B' if l_res == 'Red' else 'R'
    for k in range(l - 1):
        print('?', k + 1, *same_rb1)
        res = input()
        ans[k] = res[0]
    for k in range(l + n, 2 * n):
        print('?', k + 1, *same_rb1)
        res = input()
        ans[k] = res[0]
    for k in range(l, l + n - 1):
        print('?', k + 1, *same_rb2)
        res = input()
        ans[k] = res[0]
    return ''.join(ans)


n = int(input())
print('!', solve(n))

Solution (Python):
import sys

N = int(input())

def inread():
    a = sys.stdin.readline()
    if a[0] == "-":
        return 0/0
    return a[0]


ans = [" "] * (2*N)

def nibu(R,B):
    if abs(R-B)==1:
        return min(R,B),max(R,B)+N-1
    c = (R+B)//2
    print("?",*range(c+1,c+N+1),flush=True)
    a = inread()
    if a == 'R':
        return nibu(c,B)
    else:
        return nibu(R,c)

print("?",*range(1,N+1),flush=True)
if inread() == "R":
    R,B = nibu(0,N)
else:
    R,B = nibu(N,0)

neutral1 = " ".join([str(i) for i in range(R+2,B+1)])
neutral2 =  " ".join([str(i) for i in range(1,R+1)]) + " " + " ".join([str(i)for i in range(B+2,2*N+1)])
for i in range(R+1):
    print("? "+neutral1+" "+str(i+1),flush=True)
    ans[i] = inread()
for i in range(R+2,B+1):
    print("? " + neutral2 +" " + str(i),flush=True)
    ans[i-1] = inread()
for i in range(B+1,2*N+1):
    print("? "+ neutral1+" "+str(i),flush=True)
    ans[i-1] = inread()

print("! "+"".join(ans))

Solution (Python):
N = int(input())

def query(m):
    q = ' '.join(['?']+[str(i+1) for i in range(m,N+m)])
    print(q)
    return input()[0]

init = query(0)
l = 0
r = N
m = N//2
for i in range(10):
    res = query(m)
    if res == init:
        l = m
    else:
        r = m
    m = (l+r)//2
if res == init:
    even = [str(i+1) for i in range(m+1,m+N)]
    l = m+1
    r = m+N-1
else:
    even = [str(i+1) for i in range(m,m+N-1)]
    l = m
    r = m+N-2

ans = [0]*(2*N)
for i in range(2*N):
    if i<l or r<i:
        q = ' '.join(['?']+even+[str(i+1)])
        print(q)
        ans[i] = input()[0]


even = [str(i+1) for i in range(l-1)]+[str(i+1) for i in range(r+2,2*N)]
for i in range(l,r+1):
    q = ' '.join(['?']+even+[str(i+1)])
    print(q)
    ans[i] = input()[0]

print(' '.join(['!',''.join(ans)]))

Solution (Python):
import sys

def query(n):
    q = ""
    for i in range(N):
        q += str(n + i)
        if i != N-1:
            q += " "
    
    print ("?" , q)

    ret = input()

    return ret


N = int(input())

l = 1
r = N + 1

lc = query(1)
if lc == "Red":
    rc = "Blue"
elif lc == "Blue":
    rc = "Red"
else:
    sys.exit()

while r - l != 1:

    m = (l + r) // 2
    mc = query(m)

    if mc == lc:
        l = m
        lc = mc
    else:
        r = m
        rc = mc

ans = [None] * (2 * N)
ans[l-1] = lc[0]
ans[r+N-2] = rc[0]


eqstr = ""
for i in range(N-1):
    eqstr += str(l + 1 + i)
    eqstr += " "



for i in range(l - 1):
    i += 1
    print ("?",eqstr + str(i))
    rec = input()
    ans[i-1] = rec[0]

for i in range(2 * N - (r + N - 1)):
    i += r+N
    print ("?",eqstr + str(i))
    rec = input()
    ans[i-1] = rec[0]



BN = 0
RN = 0
eqstrT = ""
for i in range(N * 2):

    if ans[i] == "R" and RN < N // 2:
        eqstrT = eqstrT + str(i+1) + " "
        RN += 1
    if ans[i] == "B" and BN < N // 2:
        eqstrT = eqstrT + str(i+1) + " "
        BN += 1
    

for i in range(N * 2):
    if ans[i] == None:
        print ("?",eqstrT + str(i + 1))
        rec = input()
        ans[i] = rec[0]

print ("!","".join(ans))

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
flush = sys.stdin.flush()

def solve():
    n = I()
    ans = [-1]*(2*n)
    q = [i+1 for i in range(n)]
    que = ["?"]+q
    print(*que)
    flush
    t = input()
    T = t
    l = 0
    r = n
    while r-l > 1:
        m = (l+r) >> 1
        q = [i+m+1 for i in range(n)]
        que = ["?"]+q
        print(*que)
        flush
        t = input()
        if t == T:
            l = m
        else:
            r = m
    if T[0] == "R":
        ans[l] = "R"
        ans[l+n] = "B"
    else:
        ans[l] = "B"
        ans[l+n] = "R"
    Q = [i+r+1 for i in range(n-1)]
    for i in range(1,2*n+1):
        if ans[i-1] != -1:
            continue
        if i in Q:
            continue
        q = Q+[i]
        que = ["?"]+q
        print(*que)
        flush
        t = input()
        if t[0] == "R":
            ans[i-1] = "R"
        else:
            ans[i-1] = "B"
    Q_ = []
    for i in range(2*n):
        if len(Q_) == (n>>1):
            break
        if ans[i] == "R" and i+1 not in Q:
            Q_.append(i+1)
    for i in range(2*n):
        if len(Q_) == n-1:
            break
        if ans[i] == "B" and i+1 not in Q:
            Q_.append(i+1)
    for i in Q:
        q = Q_+[i]
        que = ["?"]+q
        print(*que)
        flush
        t = input()
        if t[0] == "R":
            ans[i-1] = "R"
        else:
            ans[i-1] = "B"
    ans = ["! "]+ans
    print(*ans,sep = "")
    return


if __name__ == "__main__":
    solve()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    ans = [-1]*(2*n)
    q = [i+1 for i in range(n)]
    que = ["?"]+q
    print(*que,flush = True)
    t = input()
    T = t
    l = 0
    r = n
    while r-l > 1:
        m = (l+r) >> 1
        q = [i+m+1 for i in range(n)]
        que = ["?"]+q
        print(*que,flush = True)
        t = input()
        if t == T:
            l = m
        else:
            r = m
    if T[0] == "R":
        ans[l] = "R"
        ans[l+n] = "B"
    else:
        ans[l] = "B"
        ans[l+n] = "R"
    Q = [i+r+1 for i in range(n-1)]
    for i in range(1,2*n+1):
        if ans[i-1] != -1:
            continue
        if i in Q:
            continue
        q = Q+[i]
        que = ["?"]+q
        print(*que,flush = True)
        t = input()
        if t[0] == "R":
            ans[i-1] = "R"
        else:
            ans[i-1] = "B"
    Q_ = []
    for i in range(2*n):
        if len(Q_) == (n>>1):
            break
        if ans[i] == "R" and i+1 not in Q:
            Q_.append(i+1)
    for i in range(2*n):
        if len(Q_) == n-1:
            break
        if ans[i] == "B" and i+1 not in Q:
            Q_.append(i+1)
    for i in Q:
        q = Q_+[i]
        que = ["?"]+q
        print(*que,flush = True)
        t = input()
        if t[0] == "R":
            ans[i-1] = "R"
        else:
            ans[i-1] = "B"
    ans = ["! "]+ans
    print(*ans,sep = "")
    return


if __name__ == "__main__":
    solve()

Solution (Python):
import sys


def query(li):
    
    
    
    
    
    
    

    for i in range(len(li)):
        li[i] += 1
    print("?", *li)

    
    
    
    

    sys.stdout.flush()
    res = input()
    return res

n = int(input())


tmp = [j for j in range(n)]
ans = query(tmp)
if ans == "Blue":
    b = 0
    r = n
else:
    b = n
    r = 0

while abs(b - r) > 1:
    mid = (b + r) // 2
    tmp = [j + mid for j in range(n)]
    if query(tmp) == "Blue":
        b = mid
    else:
        r = mid
ans = [None]*(2*n)

if b < r:
    ans[b] = "B"
    ans[(b+n) % (2*n)] = "R"
else:
    ans[r] = "R"
    ans[(r+n) % (2*n)] = "B"

min_rb = min(r, b)
tmp = [j + min_rb + 1 for j in range(n-1)]
tmp2 = [(j + min_rb + n + 1) % (2*n) for j in range(n-1)]

for i in range(2*n):
    if ans[i] is None:
        if i in tmp:
            c = query(tmp2+[i])
        else:
            c = query(tmp+[i])
    else:
        continue
    if c == "Blue":
        ans[i] = "B"
    else:
        ans[i] = "R"
print("!", "".join(ans))

Solution (Python):
def query(x):
    print("? " + " ".join(map(lambda x: str(x+1), x)), flush = True)
    return input()[0]
    
n = int(input())
A, B, l, r = [], [], [], []
chg1 = [i   for i in range(n)]
chg2 = [i+n for i in range(n)]

opt = ['Z' for i in range(n * 2)]

a, b = query(chg1), -1
if a == 'B': b = 'R'
else: b = 'B'

while len(chg1) > 1:
    H = len(chg1) // 2
    l = chg1[:H] + chg2[H:]
    r = chg2[:H] + chg1[H:]
    if query(A + l) == a:
        A += chg2[H:]
        B += chg1[H:]
        chg1 = chg1[:H]
        chg2 = chg2[:H]
    else:
        A += chg1[:H]
        B += chg2[:H]
        chg1 = chg1[H:]
        chg2 = chg2[H:]

opt[chg1[0]] = a
opt[chg2[0]] = b
for x in A:
    opt[x] = query(B + [x])
for x in B:
    opt[x] = query(A + [x])
print("! " + "".join(opt), flush = True)

Solution (Python):
n=int(input())
q=["?"]+[str(i) for i in range(1,n+1)]
print(*q)
color=input()
ans=[0]*(2*n+1)
left=1
right=n+1
while right-left>1:
    mid=(right+left)//2
    q=["?"]+[str(i) for i in range(mid,n+mid)]
    print(*q)
    b=input()
    if color==b:
        left=mid
    else:
        right=mid
ans[left]=color[0]
if color=="Red":
    zzz="Blue"
else:
    zzz="Red"
ans[left+n]=zzz[0]
k=left
q=["?"]+[str(i) for i in range(k+1,n+k)]+["0"]

for i in range(n+k+1,2*n+1):
    q[-1]=str(i)
    print(*q)
    b=input()
    ans[i]=b[0]
    
for i in range(1,k):
    q[-1]=str(i)
    print(*q)
    b=input()
    ans[i]=b[0]
    
q=["?"]+[str(i) for i in range(1,k)]+[str(i) for i in range(n+k+1,2*n+1)]+["0"]
for i in range(k+1,n+k):
    q[-1]=str(i)
    print(*q)
    b=input()
    ans[i]=b[0]
print("! "+"".join(ans[1:]))

Solution (Python):

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()


def kiku(a):
    print("?",' '.join(map(str,list(range(a,a+N)))))


kiku(1)

T = input()
if T == '-1':
    sys.exit(-1)

baseT = T

setL = {1}
setR = {N+1}
bmid = INF
bbmid = INF
while True:
    L = max(setL)
    R = min(setR)

    if abs(R-L) == 1:
        break

    mid = (L + R)//2
    kiku(mid)
    T = input()
    if T == baseT:
        setL.add(mid)
    else:
        setR.add(mid)

X = R

def kikuX(i,X):
    print("?",' '.join(map(str,list(range(X,X+N-1)))),str(i))

ans = [0]*(2*N)

Reds = []
Blues = []

for i in range(1,X):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T

for i in range(X+N-1,N*2+1):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T




for i in range(X,X+N-1):
    k = Reds[:N//2] + Blues[:N//2] + [i]
    print("?", ' '.join(map(str,k)))
    ans[i-1] = input()[0]

print('!', ''.join(map(str,ans)))

Solution (Python):
N = int(input())
def query(q):
    print('?', end = ' ')
    for i in q[:-1]:
        print(i+1, end = ' ')
    print(q[-1]+1)
back = []
q = list(range(0, N))
query(q)
T = input()
ok = 0
ng = N
c = T
while ng-ok>1:
    mid = (ok+ng)//2
    query(list(range(mid, mid+N)))
    T = input()
    if T == c:
        ok = mid
    else:
        ng = mid
eq1 = list(range(ng, ng+N-1))
eq2 = list(range(ng-1))+list(range(ng+N, N*2))
a = ng

ans = ['n']*(N*2)
for i in range(N*2):
    if a<=i<a+N-1:
        query(eq2+[i])
        T = input()
        if T == '-1':
            a = 1/0
        if T == 'Red':
            ans[i] = 'R'
        else:
            ans[i] = 'B'
    else:
        query(eq1+[i])
        T = input()
        if T == '-1':
            a = 1/0
        if T == 'Red':
            ans[i] = 'R'
        else:
            ans[i] = 'B'
print('!', end = ' ')
print(*ans, sep = '')

Solution (Python):
import queue
import math
import copy
"""
N = int(input())



A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
def nt(s):
	if s == "Blue":
		return "Red"
	return "Blue"
N = int(input())
A = ["" for i in  range(N*2)]

print(" ".join(["?"]+[str(i) for i in range(1,N+1)]), flush=True)

s = input()

t = 0
b = N

while b-t > 1:
	m = (t+b)//2
	print(" ".join(["?"]+[str(i) for i in range(1,m+1)]+[str(i) for i in range(N+1,2*N-m+1)]), flush=True)
	r = input()
	if s == r:
		b = m
	else:
		t = m

A[b-1] = s
A[N*2-b] = nt(s)
known = [str(b), str(N*2-b+1)]


ask = [str(i) for i in range(1,b+1)]+[str(i) for i in range(N+1,2*N-b+2)]
asks = copy.copy(ask)
for a in ask:
	if a in known:
		continue
	asks.remove(a)
	print(" ".join(["?"]+asks), flush=True)
	r = input()
	if r != s:
		A[int(a)-1] = s
		known.append(a)
	else:
		A[int(a)-1] = nt(s)
	asks.append(a)

ask = [str(i) for i in range(b,N+1)]+[str(i) for i in range(2*N-b+1,N*2+1)]

asks = copy.copy(ask)
for a in ask:
	if a in known:
		continue
	asks.remove(a)
	print(" ".join(["?"]+asks), flush=True)
	r = input()
	if r != s:
		A[int(a)-1] = s
		known.append(a)
	else:
		A[int(a)-1] = nt(s)
	asks.append(a)
print("! "+"".join(["B" if r == "Blue" else "R" for r in A]))

Solution (Python):
N = int(input())
L = list(range(1, 2*N+1))
print("?", " ".join(map(str, L[:N])))
color_init = input()
rev = {"Red": "Blue", "Blue": "Red"}
col_t = 0
col_f = N
while col_t + 1 < col_f:
    c = (col_t+col_f)//2
    print("?", " ".join(map(str, L[c:c+N])))
    color = input()
    if color == color_init:
        col_t = c
    else:
        col_f = c
Ans = ["_"] * (2*N)
Ans[col_t] = color_init[0]
Ans[col_t+N] = rev[color_init][0]
E1 = list(range(col_t+1, col_t+N))
E2 = [i for i in range(2*N) if i not in E1 and i != col_t and i != col_t+N]
assert len(E2) == len(E1)
for i in range(2*N):
    if Ans[i] != "_":
        continue
    if i not in E1:
        E = E1
    else:
        E = E2
    print("?", i+1, " ".join([str(i+1) for i in E]))
    Ans[i] = input()[0]

print("!", "".join(Ans))

Solution (Python):
from itertools import chain
def query(indices):
    print('? '+' '.join(map(lambda x: str(x+1),indices)), flush=True)
    r = input()
    if r == '-1':
        exit()
    return r == 'Red'

def answer(colors):
    print('! '+''.join(map(lambda x: 'R' if x else 'B', colors)), flush=True)

def bisect(ng, ok, judge):
    while abs(ng-ok) > 1:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

from random import shuffle

def solve(N):
    

    check = lambda i: query(range(i,i+N)) if i <= N else query(chain(range(i-N),range(i,2*N)))

    L = list(range(2*N))
    shuffle(L)
    x = L[-1]
    orig = check(x)
    for y in reversed(L[:-1]):
        if orig != check(y):
            break

    if y < x:
        x -= N*2


    while abs(x-y) > 1:
        mid = (x+y)//2
        r = check((mid)%(2*N))
        if r == orig:
            x = mid
        else:
            y = mid

    x %= 2*N

    res = [None]*(2*N)
    a,b = x, (x+N)%(2*N)
    res[a] = orig
    res[b] = not orig
    
    n1 = list(range(a+1,b)) if a < b else list(chain(range(a+1,2*N),range(0,b)))
    
    n2 = list(range(b+1,a)) if b < a else list(chain(range(b+1,2*N),range(0,a)))
    for i in n1:
        res[i] = query(n2+[i])
    for i in n2:
        res[i] = query(n1+[i])

    answer(res)


if __name__ == '__main__':
    N = int(input())
    solve(N)

Solution (Python):
from sys import stdout
def Q(a):
    print '?', ' '.join(map(str, a))
    stdout.flush()
    res = raw_input().strip()
    return res[0]
def A(a):
    print '!', ''.join(a)
    quit()
n = int(raw_input())
a = range(1, n + 1)
b = range(n + 1, n * 2 + 1)
p = Q(a)
pp = 'R' if p == 'B' else 'B'
ans = [0] * (2 * n)
lo = 0
hi = n
while lo + 1 < hi:
    mid = (lo + hi) / 2
    r = Q(a[:-mid] + b[-mid:])
    if p == r:
        lo = mid
    else:
        hi = mid
ans[n-hi] = p
ans[2*n-hi] = pp
c = a[:-lo] + b[-lo:] if lo else a[:]
for j in xrange(n):
    if j == n - hi:
        continue
    t = c[:j] + c[j+1:] + [b[-hi]]
    r = Q(t)
    if p == r:
        ans[c[j]-1] = pp
    else:
        ans[c[j]-1] = p
c = a[-lo:] + b[:-lo] if lo else b[:]
for j in xrange(n):
    t = c[:j] + c[j+1:] + [a[-hi]]
    r = Q(t)
    if p == r:
        ans[c[j]-1] = pp
    else:
        ans[c[j]-1] = p
A(ans)

Solution (Python):
def main():
	def query(*args):
		print("? " + " ".join(str(x + 1) for x in args), flush=True)
		answer = input()
		if answer == '-1':
			exit()
		return answer[0]
	
	def answer():
		print("! " + "".join(arr))
		exit()
	
	n = int(input())
	
	B = 'B'
	R = 'R'
	
	arr = [' '] * 2 * n
	
	tmp = query(*range(0, n))
	
	if n == 1:
		if tmp == B:
			arr = ['B', 'R']
		else:
			arr = ['R', 'B']
		answer()
	
	if tmp == B:
		B, R = R, B
	
	
	
	
	
	
	
	l = 0
	r = n
	while r - l != 1:
		m = l + r >> 1
		tmp = query(*range(m, m + n))
		if tmp == B:
			r = m
		else:
			l = m
	
	arr[l] = R
	arr[l + n] = B
	
	for i in range(l + 1, l + n):
		lst = list(range(l, i)) + list(range(i + 1, l + n + 1))
		tmp = query(*lst)
		if tmp == R:
			arr[i] = B
		else:
			arr[i] = R
	
	for i in range(l):
		tmp = query(i, *range(l + 1, l + n))
		arr[i] = tmp
	
	for i in range(l + n + 1, 2 * n):
		tmp = query(i, *range(l + 1, l + n))
		arr[i] = tmp
	
	answer()
	
	return 0

main()

Solution (Python):



import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())

def q(i): 
    res = ["?"] + list(map(str,range(i,i+n)))
    print(*res)
    sys.stdout.flush()
    I = input()
    return I

c0 = q(1)

ok = 1
ng = n+1
while(abs(ok-ng) > 1):
    mid = (ok + ng)//2
    c = q(mid)
    if c0 == c: ok = mid
    else: ng = mid


ans = [-1]*(2*n+1)
ans[ok] = c0[0]
ans[ng+n-1] = "B" if c0 == "Red" else "R"

L = list(range(2*n+1))

g1 = L[ng:ng+n-1]
g2 = L[1:ok] + L[ng+n:]





for i in g1:
    res = ["?"] + g2[:] + [i]
    print(*res)    
    sys.stdout.flush()
    c = input()
    ans[i] = c[0]

for i in g2:
    res = ["?"] + g1[:] + [i]
    print(*res)    
    sys.stdout.flush()
    c = input()
    ans[i] = c[0]


L = "".join(ans[1:])
a = ["!"] + [L]
print(*a)
sys.stdout.flush()

Solution (Python):
def s1(i):
    print("?", *[(i+j)%(2*N)+1 for j in range(N)])
    return 1 if input() == "Red" else 0

def s2(k, i):
    if (i-k) % (2*N) < N:
        print("?", *sorted([(k+j+N)%(2*N)+1 for j in range(N-1)] + [i+1]))
    else:
        print("?", *sorted([(k+j)%(2*N)+1 for j in range(N-1)] + [i+1]))
    return 1 if input() == "Red" else 0

N = int(input())
ANS = [-1] * (2*N)
if s1(0):
    r = 0
    b = N
else:
    b = 0
    r = N
while abs(r - b) > 1:
    m = (r+b) // 2
    if s1(m):
        r = m
    else:
        b = m

if r < b:
    ANS[r] = 1
    ANS[r+N] = 0

else:
    ANS[b] = 0
    ANS[b+N] = 1

k = max(r, b)
for i in range(2*N):
    if ANS[i] >= 0: continue
    ANS[i] = s2(k, i)

print("!", "".join(["R" if a else "B" for a in ANS]))