hneohis | 2015-04-04 21:29:15
Author
RunID 1970
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define FORD(i,h,l) for(int i=(h);i>=(l);--i)
typedef long long LL;
//#define maxn 100010
//#define maxm 500010
//#define mm 142857
map<int,int> M;
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n,m;
while (scanf("%d%d",&n,&m)!=EOF)
{
M.clear();
FOR(i,1,n)
{
int w;
scanf("%d",&w);
map<int,int>::iterator it=M.find(w);
if (it==M.end())
M.insert(make_pair(w,1));
else
it->second++;
}
FOR(i,1,m)
{
int w;
scanf("%d",&w);
map<int,int>::iterator it=M.find(w);
if (it==M.end())
printf("0\n");
else
{
printf("%d\n",it->second);
M.erase(it);
}
}
}
//fclose(stdin);
//fclose(stdout);
return 0;
}