internal class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
// 숫자 카드를 담아둘 딕셔너리 <string, int> 는 <카드숫자, 카드 개수>의 의미이다.
Dictionary<string, int> numCard = new Dictionary<string, int>();
int N = int.Parse(sr.ReadLine());
// 숫자 카드 입력받기
string[] s = sr.ReadLine().Split(" ");
// 딕셔너리에 등록
for (int i = 0; i < N; i++)
{
// 등록된적 없는 카드면 새로 등록해주고 카드 개수를 1개로 해줌
if (numCard.ContainsKey(s[i]) == false)
{
numCard[s[i]] = 1;
}
// 전에 동륵된 카드면 카드 개수를 늘려줌
else
{
numCard[s[i]]++;
}
}
int M = int.Parse(sr.ReadLine());
s = sr.ReadLine().Split(" ");
// 등록된 카드면 개수를 출력, 아니면 0을 출력
for (int i = 0; i < M; i++)
{
if (numCard.ContainsKey(s[i]))
{
sw.Write(numCard[s[i]]);
}
else
{
sw.Write("0");
}
sw.Write(' ');
}
sr.Close();
sw.Close();
}
}
댓글남기기