Submission #50938793


Source Code Expand

input()
A=[0]+list(map(int,input().split()))+[-1]

mae={}
ushiro={}
for i in range(len(A)-1):
  ushiro[A[i]]=A[i+1]
  mae[A[i+1]]=A[i]

Q=int(input())
for _ in range(Q):
  t,*p=map(int,input().split())
  if t==1:
    a,x=p
    b=ushiro[a]
    ushiro[a]=x
    mae[x]=a
    ushiro[x]=b
    mae[b]=x
  else:
    x=p[0]
    a=mae[x]
    b=ushiro[x]
    ushiro[a]=b
    mae[b]=a
    del mae[x]
    del ushiro[x]

ans=[]
crr=ushiro[0]
while crr!=-1:
  ans.append(crr)
  crr=ushiro[crr]

print(*ans)

Submission Info

Submission Time
Task E - Insert or Erase
User kyopro_friends
Language Python (PyPy 3.10-v7.3.12)
Score 475
Code Size 528 Byte
Status AC
Exec Time 719 ms
Memory 228644 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 2
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 59 ms 76256 KiB
random_01.txt AC 719 ms 228644 KiB
random_02.txt AC 558 ms 182128 KiB
random_03.txt AC 475 ms 182464 KiB
random_04.txt AC 259 ms 115668 KiB
random_05.txt AC 609 ms 170944 KiB
random_06.txt AC 442 ms 129188 KiB
random_07.txt AC 524 ms 158868 KiB
random_08.txt AC 271 ms 126116 KiB
random_09.txt AC 448 ms 143504 KiB
random_10.txt AC 498 ms 126324 KiB
random_11.txt AC 405 ms 143472 KiB
random_12.txt AC 126 ms 84196 KiB
random_13.txt AC 492 ms 222636 KiB
random_14.txt AC 367 ms 152480 KiB
random_15.txt AC 314 ms 144184 KiB
random_16.txt AC 499 ms 216404 KiB
random_17.txt AC 369 ms 152664 KiB
random_18.txt AC 337 ms 143704 KiB
random_19.txt AC 236 ms 131328 KiB
random_20.txt AC 345 ms 222260 KiB
random_21.txt AC 230 ms 174996 KiB
sample_01.txt AC 59 ms 76620 KiB
sample_02.txt AC 60 ms 76552 KiB