您的位置:首页 > 其它

HDU 5199/BC 36B Gunner

2015-09-28 21:26 726 查看
读入鸟的时候直接用map存起来 询问的时候访问后清零即可

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#define scnaf scanf
#define cahr char
#define bug puts("bugbugbug");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int mod=1000000007;
const int maxn=1e6+100;
const int inf=1e9;
int a;
inline void RDF(int &ret)   //输入为负数
{
    char c;
    int sgn;
    while(c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while(c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
}
inline void RD(int &ret)   //输入为整数
{
    char c;
    do
    {
        c = getchar();
    }
    while(c < '0' || c > '9');
    ret = c - '0';
    while((c = getchar()) >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0');
    }
}
inline void OT(int a)   //输出为正数
{
    if(a >= 10)
    {
        OT(a / 10);
    }
    putchar(a % 10 + '0');
}
map<int,int>mp;
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        mp.clear();
        for(int i=0; i<n; i++)
        {
            RD(a);
            mp[a]++;
        }
        for(int i=0; i<m; i++)
        {
            RD(a);
            OT(mp[a]);
            puts("");
            mp[a]=0;
        }
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: