문제 : https://www.acmicpc.net/problem/10815
코드
num = int(input())
num_list = list(map(int, input().split()))
snum = int(input())
snum_list = list(map(int, input().split()))
dic = {}
for s in snum_list:
dic[s] = 0
for n in num_list:
if n in dic:
dic[n] = 1
for d in dic:
print(dic[d], end=" ")
시간 초과를 방지하기 위해 딕셔너리를 사용해 상근이 이미 가지고 있는 숫자이면 딕셔너리의 값을 1로 변경하여 출력한다.
'코딩테스트 > 백준 (python)' 카테고리의 다른 글
백준 / 9012번 / 괄호 / python 파이썬 (0) | 2024.07.26 |
---|---|
백준 / 1439번 / 뒤집기 / python 파이썬 (0) | 2024.07.16 |
백준 / 25206번 / 너의 평점은 / python 파이썬 (1) | 2024.06.07 |
백준 / 14425번 / 문자열 집합 / python 파이썬 (0) | 2024.06.05 |
백준 / 2566번 / 최댓값 / python 파이썬 (0) | 2024.06.02 |