- A world where the numbers are interchangeable, and the problem is to sort the given numbers according to the scale in the other world.
- The size of the problem is not so large that you can just replace the string and sort.
- maketrans python
def solve(BS, N, SS):
import string
trans = str.maketrans("".join(BS), string.digits)
SS.sort(key=lambda s: int(s.translate(trans)))
return SS
def main():
# parse input
BS = list(input().decode('ascii').split())
N = int(input())
SS = [input().strip().decode('ascii') for i in range(N)]
print(*solve(BS, N, SS), sep="\n")
submitted #15126254 - AtCoder Regular Contest 009
This page is auto-translated from /nishio/arc009_2 using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.