您的位置:首页 > 其它

UVALive 6959 Judging Troubles map应用

2015-08-26 12:29 197 查看
[code]#include<bits/stdc++.h>
using namespace std;

map<string,int>m;
int a[200000+5];

int main()
{
    int i,n,tot;
    string s;
    while(~scanf("%d",&n))
    {
        m.clear();
        tot=0;
        memset(a,0,sizeof(a));
        for(i=0;i<n;i++)
        {
            cin>>s;
            if(m[s]==0)
            {
                tot++;
                //printf("%d\n",tot);
                m[s]=tot;
                a[tot]=1;
            }
            else
            {
                a[m[s]]++;
            }
        }
        int ans=0;
        for(i=0;i<n;i++)
        {
            cin>>s;
            if(m[s]==0) ;
            else if(a[m[s]]!=0)
            {
                ans++;
                a[m[s]]--;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: