10816 : ์ˆซ์ž ์นด๋“œ 2

10816 : ์ˆซ์ž ์นด๋“œ 2#

  • https://d2gd6pc034wcta.cloudfront.net/tier/7.svg ์‹ค๋ฒ„ 4

์‹œ๊ฐ„์ œํ•œ

๋ฉ”๋ชจ๋ฆฌ์ œํ•œ

์ •๋‹ต๋น„์œจ

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