알고리즘
[백준, 파이썬, 2776번] 암기왕
hminor
2023. 9. 16. 10:25
반응형
풀이
- set 안에 있는 요소를 in 으로 찾을 경우
- hash 값으로 찾다보니 빠르게 찾을 수 있다는 말을 들었어서
- 적용해보니 간단하게 문제를 해결할 수 있었다.
import sys
input = sys.stdin.readline
for i in range(int(input())):
n,note1 = int(input()),set(map(int,input().rstrip('\n').split()))
m,note2 = int(input()),list(map(int,input().rstrip('\n').split()))
for i in note2:
if i in note1: print(1)
else: print(0)