Farewell Round A 2023. Task 3
Python Only
# Competition Variant 1 (All Points)
T=int(input())
for t in range(T):
N=int(input())
cards=input().split()
cards_set=set()
result=[]
for i in range(N):
if cards[i] not in cards_set:
cards_set.update([cards[i]])
result.append(cards[i])
elif result[-1]!=cards[i]:
result='IMPOSSIBLE'
break
# print(i,result)
if result!='IMPOSSIBLE': result=' '.join(result)
print('Case #{}: {}'.format((t+1),result))
No comments:
Post a Comment