19642022-12-12 14:16:4912BotiNomekoppython3Time limit exceeded 60/1005.066s15404 KiB
read = True
if read:
  N = int(input())
  P = [int(x) for x in input().split()]
else:
  N = 5
  P = [3, 2, 3, 1, 5]
P.sort()


def ask(t):
  if read:
    print('?', *t)
    return int(input())
  else:
    c = [4, 4, 1, 1, 2]
    s = 0
    for a, b in zip(t, c):
      s += a * b
    return s


base1 = ask(P)
P[0], P[-1] = P[-1], P[0]
base2 = ask(P)
P[0], P[-1] = P[-1], P[0]

D = [0]*N
for i in range(1, N):
  if P[0] == P[i]:
    P[0], P[-1] = P[-1], P[0]
    used = base2
  else:
    used = base1
  P[0], P[i] = P[i], P[0]
  new = ask(P)
  P[0], P[i] = P[i], P[0]
  # (P0A0 + PiAi) - (P0Ai + PiA0)
  # = A0(P0-Pi) + Ai(Pi-P0)
  # = A0(P0-Pi) - Ai(P0-Pi)
  # = (A0-Ai)(P0-Pi)
  # = (Ai-A0)(Pi-P0)
  D[i] = (used - new) // (P[i] - P[0])
  if used == base2:
    P[0], P[-1] = P[-1], P[0]

I = [b for a,b in sorted(zip(D, range(N)))]
R = [None]*N
for p, i in zip(P, I):
  R[i] = p
print('!', *R)
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted18ms11504 KiB
subtask210/10
2Accepted18ms11924 KiB
3Accepted17ms12196 KiB
subtask330/30
4Accepted23ms12432 KiB
5Accepted107ms12420 KiB
6Accepted105ms12720 KiB
7Accepted105ms12732 KiB
8Accepted21ms12740 KiB
9Accepted108ms13048 KiB
subtask420/20
10Accepted351ms13392 KiB
11Accepted363ms13456 KiB
12Accepted356ms13784 KiB
13Accepted358ms13860 KiB
subtask50/40
14Time limit exceeded5.046s6204 KiB
15Time limit exceeded5.066s6236 KiB
16Accepted4.691s15404 KiB
17Accepted4.083s15116 KiB
18Time limit exceeded5.013s6424 KiB
19Time limit exceeded5.026s6368 KiB
20Time limit exceeded5.021s6636 KiB
21Time limit exceeded5.028s6412 KiB