美文网首页
1121 Damn Single (25 分)

1121 Damn Single (25 分)

作者: 我非神灵 | 来源:发表于2019-01-22 14:47 被阅读0次
    #include<iostream>
    #include<vector>
    #include<set>
    #include<cstring>
    using namespace std;
    
    int couple[100010];
    int main()  
    {
        int n, a, b, temp;
        memset(couple, -1, 100010);
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
        {
            scanf("%d%d", &a, &b);
            couple[a] = b;
            couple[b] = a;
        }
        set<int> guest;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &temp);
            guest.insert(temp);
        }
        vector<int> ans;
        for (auto iter = guest.begin(); iter != guest.end(); iter++)
        {
            if (couple[*iter] == -1)
                ans.push_back(*iter);
            if (couple[*iter] != -1 && guest.find(couple[*iter]) == guest.end())
                ans.push_back(*iter);
        }
        printf("%d\n", ans.size());
        for (int i = 0; i < ans.size(); i++)
        {
            printf("%05d", ans[i]);
            if (i < ans.size() - 1) printf(" ");
        }
        system("pause");
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:1121 Damn Single (25 分)

          本文链接:https://www.haomeiwen.com/subject/tibljqtx.html