# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133466 | tnbs10 | ZigZag (COCI17_zigzag) | Cpython 3 | 896 ms | 14924 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |