1121 Damn Single (25 分)

水题~。

const int N=1e5+10;
map<int,int> mp;
bool vis[N];
int a[10010];
int n,m;

int main()
{
    cin>>n;

    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        mp[a]=b,mp[b]=a;
    }

    cin>>m;
    for(int i=0;i<m;i++) cin>>a[i],vis[a[i]]=true;

    vector<int> res;
    for(int i=0;i<m;i++)
    {
        if(mp.count(a[i]) == 0 || !vis[mp[a[i]]])
            res.pb(a[i]);
    }

    cout<<res.size()<<endl;

    sort(res.begin(),res.end());
    for(int i=0;i<res.size();i++)
        if(i) printf(" %05d",res[i]);
        else printf("%05d",res[i]);

    //system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/fxh0707/p/14410970.html