107952024-04-13 22:54:04pythonNomekoppypy3Accepted 100/1001.529s180028 KiB
import sys
input=sys.stdin.readline

def solv():
    n = int(input())
    N = list(map(int, input().split()))
    if n==1:
        print('!',*N)
        sys.stdout.flush()
        return
    N.sort()
    NN=N[:]
    if N[0]==N[-1]:
        print('!',*N)
        sys.stdout.flush()
        return
    A=[0]*n
    print('?',*N)
    sys.stdout.flush()
    ans = int(input())
    N[0],N[-1]=N[-1],N[0]
    M=N[:]
    print('?',*N)
    sys.stdout.flush()
    newans = int(input())
    A[0]=(ans-newans)//(N[-1]-N[0])
    done=2
    i=0
    last=newans
    while done<n and N[i] != N[i+1]:
        N[i],N[i+1]=N[i+1],N[i]
        print('?',*N)
        sys.stdout.flush()
        new = int(input())
        A[i+1]=A[i]-(last-new)//(N[i+1]-N[i])
        done+=1
        i+=1
        last=new
    i=n-1
    last=newans
    while done<n and M[i] != M[i-1]:
        M[i],M[i-1]=M[i-1],M[i]
        print('?',*M)
        sys.stdout.flush()
        new = int(input())
        A[i-1]=A[i]-(last-new)//(M[i-1]-M[i])
        done+=1
        i-=1
        last=new
    #print(A)
    # NN sorted
    AA=[(A[i],i) for i in range(n)]
    AA.sort()
    for i in range(n):
        N[AA[i][1]]=NN[i]
    print('!',*N)
    sys.stdout.flush()
    return

solv()
exit()

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted43ms77176 KiB
subtask210/10
2Accepted41ms77548 KiB
3Accepted41ms77828 KiB
subtask330/30
4Accepted57ms87480 KiB
5Accepted105ms88464 KiB
6Accepted101ms88764 KiB
7Accepted98ms88604 KiB
8Accepted59ms88132 KiB
9Accepted98ms89260 KiB
subtask420/20
10Accepted157ms93984 KiB
11Accepted159ms93764 KiB
12Accepted168ms94176 KiB
13Accepted163ms94280 KiB
subtask540/40
14Accepted1.529s180028 KiB
15Accepted1.493s179788 KiB
16Accepted1.348s178844 KiB
17Accepted1.24s179392 KiB
18Accepted1.412s178708 KiB
19Accepted1.414s178428 KiB
20Accepted1.411s178540 KiB
21Accepted1.371s178876 KiB