반응형
https://www.acmicpc.net/problem/1920
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
m = int(input())
targets = list(map(int, input().split()))
answer = [0]*m
for i in range(m):
target = targets[i]
left = 0
right = len(nums)-1
while left <= right:
mid = (left + right) // 2
if nums[mid] < target:
left = mid + 1
elif nums[mid] > target:
right = mid - 1
else: # find
answer[i] = 1
break
print(*answer)
댓글