[백준] 9536번 여우는 어떻게 울지?

거북이·2023년 3월 7일
0

백준[실버4]

목록 보기
73/91
post-thumbnail

💡문제접근

  • split()을 적절히 사용해서 울음소리가 들어있는지 아닌지 판별해서 조건에 맞는 울음소리만을 출력하면 된다.

💡코드(메모리 : 31256KB, 시간 : 40ms)

import sys
input = sys.stdin.readline

T = int(input())
for _ in range(T):
    sound_lst = list(map(str, input().strip().split()))
    result = []
    temp = []
    while True:
        input_string = input().strip()
        if input_string == "what does the fox say?":
            break
        else:
            li = list(input_string.split(" "))
            temp.append(li[-1])

    for i in sound_lst:
        if i not in temp:
            result.append(i)
    print(*result)

💡소요시간 : 17m

0개의 댓글