μ λ΅ μ½λ λ° ν΄μ€
def solution(record):
answer = []
match_table = {}
for state in record:
state = state.split()
if state[0] == "Enter":
action, ID, nickname = state
answer.append([action, ID])
if match_table.get(ID):
match_table[ID] = nickname
else:
match_table[ID] = nickname
elif state[0] == "Leave":
action, ID = state
answer.append([action, ID])
else:
action, ID, nickname = state
if match_table.get(ID):
match_table[ID] = nickname
else:
match_table[ID] = nickname
for i in range(len(answer)):
action, ID = answer[i]
if action == "Enter":
answer[i] = f"{match_table[ID]}λμ΄ λ€μ΄μμ΅λλ€."
else:
answer[i] = f"{match_table[ID]}λμ΄ λκ°μ΅λλ€."
return answer