107942024-04-13 22:39:24pythonNomekoppython3Time limit exceeded 60/1005.081s15496 KiB
import sys

input=sys.stdin.readline

def solv():
    n = int(input())
    N = [int(s) for s in 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)//(N[i-1]-N[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
1Accepted19ms11648 KiB
subtask210/10
2Accepted18ms11880 KiB
3Accepted18ms12164 KiB
subtask330/30
4Accepted23ms12324 KiB
5Accepted115ms12608 KiB
6Accepted115ms12912 KiB
7Accepted116ms13400 KiB
8Accepted24ms13108 KiB
9Accepted115ms13528 KiB
subtask420/20
10Accepted395ms14280 KiB
11Accepted388ms13984 KiB
12Accepted391ms14356 KiB
13Accepted389ms14424 KiB
subtask50/40
14Time limit exceeded5.078s6604 KiB
15Time limit exceeded5.081s6576 KiB
16Time limit exceeded5.079s6520 KiB
17Accepted4.502s15496 KiB
18Runtime error2.858s14884 KiB
19Runtime error2.903s15272 KiB
20Time limit exceeded5.064s6936 KiB
21Runtime error4.408s15456 KiB