10816 : ์ซ์ ์นด๋ 2#
์๊ฐ์ ํ |
๋ฉ๋ชจ๋ฆฌ์ ํ |
์ ๋ต๋น์จ |
---|---|---|
1์ด |
256MB |
37.002% |
์ซ์ ์นด๋๋ ์ ์ ํ๋๊ฐ ์ ํ์ ธ ์๋ ์นด๋์ด๋ค. ์๊ทผ์ด๋ ์ซ์ ์นด๋ N๊ฐ๋ฅผ ๊ฐ์ง๊ณ ์๋ค. ์ ์ M๊ฐ๊ฐ ์ฃผ์ด์ก์ ๋, ์ด ์๊ฐ ์ ํ์๋ ์ซ์ ์นด๋๋ฅผ ์๊ทผ์ด๊ฐ ๋ช ๊ฐ ๊ฐ์ง๊ณ ์๋์ง ๊ตฌํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
import sys, os
problem_num = "10816"
path = os.getcwd() + f"\\txt\\{problem_num}" + ".txt"
sys.stdin = open(path, "r")
# input setting
n = int(sys.stdin.readline())
second_line = list(map(int, sys.stdin.readline().split()))
m = int(sys.stdin.readline())
fourth_line = list(map(int, sys.stdin.readline().split()))
# hash table
myhash = {}
for i in second_line:
if i in myhash:
myhash[i] += 1
else:
myhash[i] = 1
for j in fourth_line:
if j in myhash:
print(myhash[j], end=" ")
else:
print(0, end=" ")
3 0 0 1 2 0 0 2