Submission #62628968


Source Code Expand

def query(s, t):
	print('?', s + 1, t + 1)
	return int(input())

N = int(input())
Z = query(0, 1)
X = [-1, Z] + [query(0, k) for k in range(2, N)]
Y = [Z, -1] + [query(1, k) for k in range(2, N)]

Q = [(-1, 0, 0), (1, 0, 1)]
for k in range(2, N):
	if X[k] < Z and Y[k] < Z: Q += [(0, X[k], k)] # mid
	elif X[k] < Y[k]: Q += [(-2, -X[k], k)] # left
	else: Q += [(2, X[k], k)] # right
Q.sort()
P, Q = [-1] * N, [v[2] for v in Q]
for x in range(N): P[Q[x]] = x

All = query(Q[0], Q[-1])
A = [Y[Q[x]] - Y[Q[x + 1]] for x in range(0, P[0])]\
  + [(X[Q[0]] + X[Q[-1]] - All) if Q[0] != 0 else (All - query(Q[1], Q[-1]))]\
  + [X[Q[x]] + Y[Q[x]] - Z for x in range(P[0] + 1, P[1])]\
  + [(Y[Q[0]] + Y[Q[-1]] - All) if Q[-1] != 1 else (All - query(Q[0], Q[-2]))]\
  + [X[Q[x]] - X[Q[x - 1]] for x in range(P[1] + 1, N)]

print("!", *[x + 1 for x in P], *A)

Submission Info

Submission Time
Task C - Range Sums 2
User KumaTachiRen
Language Python (PyPy 3.10-v7.3.12)
Score 600
Code Size 873 Byte
Status AC
Exec Time 180 ms
Memory 84264 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 1
AC × 41
Set Name Test Cases
Sample 00-sample-001.txt
All 00-sample-001.txt, 01-random-001.txt, 01-random-002.txt, 01-random-003.txt, 01-random-004.txt, 01-random-005.txt, 01-random-006.txt, 01-random-007.txt, 01-random-008.txt, 01-random-009.txt, 01-random-010.txt, 01-random-011.txt, 01-random-012.txt, 01-random-013.txt, 01-random-014.txt, 01-random-015.txt, 02-large-001.txt, 02-large-002.txt, 02-large-003.txt, 02-large-004.txt, 02-large-005.txt, 02-large-006.txt, 02-large-007.txt, 02-large-008.txt, 02-large-009.txt, 02-large-010.txt, 03-small-001.txt, 03-small-002.txt, 03-small-003.txt, 03-small-004.txt, 03-small-005.txt, 03-small-006.txt, 03-small-007.txt, 03-small-008.txt, 03-small-009.txt, 03-small-010.txt, 03-small-011.txt, 03-small-012.txt, 03-small-013.txt, 03-small-014.txt, 03-small-015.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 63 ms 76272 KiB
01-random-001.txt AC 167 ms 83796 KiB
01-random-002.txt AC 75 ms 81168 KiB
01-random-003.txt AC 99 ms 81356 KiB
01-random-004.txt AC 66 ms 76272 KiB
01-random-005.txt AC 144 ms 83548 KiB
01-random-006.txt AC 134 ms 83848 KiB
01-random-007.txt AC 87 ms 81968 KiB
01-random-008.txt AC 174 ms 83640 KiB
01-random-009.txt AC 148 ms 83864 KiB
01-random-010.txt AC 161 ms 84264 KiB
01-random-011.txt AC 132 ms 83836 KiB
01-random-012.txt AC 111 ms 83808 KiB
01-random-013.txt AC 135 ms 83816 KiB
01-random-014.txt AC 141 ms 83492 KiB
01-random-015.txt AC 148 ms 83876 KiB
02-large-001.txt AC 178 ms 83384 KiB
02-large-002.txt AC 179 ms 83368 KiB
02-large-003.txt AC 176 ms 83464 KiB
02-large-004.txt AC 178 ms 83540 KiB
02-large-005.txt AC 179 ms 83444 KiB
02-large-006.txt AC 180 ms 83644 KiB
02-large-007.txt AC 177 ms 83392 KiB
02-large-008.txt AC 176 ms 83620 KiB
02-large-009.txt AC 169 ms 83612 KiB
02-large-010.txt AC 169 ms 83344 KiB
03-small-001.txt AC 63 ms 76412 KiB
03-small-002.txt AC 64 ms 76264 KiB
03-small-003.txt AC 64 ms 76420 KiB
03-small-004.txt AC 64 ms 76236 KiB
03-small-005.txt AC 63 ms 76304 KiB
03-small-006.txt AC 63 ms 76284 KiB
03-small-007.txt AC 64 ms 76296 KiB
03-small-008.txt AC 64 ms 76608 KiB
03-small-009.txt AC 62 ms 76264 KiB
03-small-010.txt AC 62 ms 76408 KiB
03-small-011.txt AC 65 ms 76308 KiB
03-small-012.txt AC 63 ms 76636 KiB
03-small-013.txt AC 62 ms 76552 KiB
03-small-014.txt AC 62 ms 76296 KiB
03-small-015.txt AC 62 ms 76356 KiB