Submission #133466

#TimeUsernameProblemLanguageResultExecution timeMemory
133466tnbs10ZigZag (COCI17_zigzag)Cpython 3
80 / 80
896 ms14924 KiB
k, n = map(int, input().split()) a = [[] for i in range(26)] for i in range(k): x = input() a[ord(x[0]) - 97].append(x) for i in range(26): a[i].sort() # print(a[i]) # napraviti [[adam, az], [ba, bd]] i onda samo šaltati # kad se uzme jednom a da se uzme adam i baci ga se na kraj # [adam, az] -> [az, adam] # # uvijek uzeti prvu u listi tog slova r = [input() for i in range(n)] for i in r: print(a[ord(i) - 97][0]) a[ord(i) - 97].append(a[ord(i) - 97].pop(0))
#Verdict Execution timeMemoryGrader output
Fetching results...