cool hamsters never sleep
백준 14425. 문자열 집합 본문
import sys
n, k = map(int, input().split())
s = set()
for i in range(n) :
s.add(sys.stdin.readline())
cnt = 0
for i in range (k) :
new_s = sys.stdin.readline()
if new_s in s :
cnt = cnt +1
print(cnt)
우선 시간초과가 많이 난다길래
import sys 스근하게 데려와서 sys.stdin.readline()으로 입력받았고요
중복 제거 후
검사해야 하는 문자열은 들어오는 족족 중복 제거한 문자열에 확인하여
문자 세는 변수에 저장...
이후 출력했습니다.
'Python Algorithm' 카테고리의 다른 글
백준 10815. 숫자 카드 (0) | 2022.08.23 |
---|---|
백준 10989. 수 정렬하기 3 (220902 수정 : 미해결) (0) | 2022.08.23 |
백준 1037. 약수 (0) | 2022.08.23 |
백준 1934. 최소공배수 (0) | 2022.08.22 |
백준 1181. 단어 정렬 (0) | 2022.08.22 |
Comments