백준 알고리즘

백준 10815 파이썬

KokoaJelly 2023. 2. 16. 15:30

https://www.acmicpc.net/problem/10815

 

10815번: 숫자 카드

첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10,

www.acmicpc.net

input_data = int(input())
nums_data = set(map(int, input().split()))

input_data_2 = int(input())
nums = list(map(int, input().split()))

for i in nums:
    if i in nums_data:
        print(1, end = " ")
    else:
        print(0, end = " ")

원래는 이진탐색으로 풀어야 하지만, 그냥 set을 사용하여 풀었다. 

그렇게 어렵지는 않는 문제다.