백준 22233 가희와 키워드 / python

이유참치·2026년 3월 3일

백준

목록 보기
229/249

문제 : 22233

풀이 point

N, M 크기가 매우 크기 때문에 일반적인 리스트에 저장하면 탐색에 매우 많은 시간이 걸린다.

map을 활용하여 키워드를 저장하고, 에세이에 키워드가 사용되면 키워드를 map에서 삭제한다.

풀이 코드

import sys
input = sys.stdin.readline

N, M = map(int, input().split())

keyword = {}

for _ in range(N):
  keyword[input().strip()] = True


for _ in range(M):
  write = input().strip().split(',')
  for word in write:
    keyword.pop(word, None)

  print(len(keyword))
profile
임아리 - 대학생

0개의 댓글