http://poj.org/problem?id=3615

基础题 狂STL

#include <bits/stdc++.h>

using namespace std;

set<string> sa, sc;
vector<string> vb;
int main()
{
    string str;
    int a, b, c;
    while(cin >> a >> b >> c)
    {
        sa.clear();
        sc.clear();
        vb.clear();
        for (int i = 0; i < a; i++)
        {
            cin >> str;
            sa.insert(str);
        }
        for (int i = 0; i < b; i++)
        {
            cin >> str;
            vb.push_back(str);
        }
        for (int i = 0; i < c; i++)
        {
            cin >> str;
            sc.insert(str);
        }
        int cnt  = 0;
        for (int i = 0; i < b; i++)
        {
            string tstr = vb[i];
            if (sa.find(tstr) != sa.end() && sc.find(tstr) == sc.end())
            {
                if(cnt++ == 0)
                {
                    cout << tstr;
                }
                else cout << " " << tstr;
            }
        }
        if (cnt == 0) cout << "No enemy spy";
        cout << endl;
    }
    return 0;

}

 

相关文章:

  • 2021-05-15
  • 2021-12-16
  • 2022-12-23
  • 2021-07-27
  • 2021-07-29
  • 2021-12-16
猜你喜欢
  • 2022-03-01
  • 2021-10-22
  • 2021-08-15
  • 2022-01-25
  • 2021-07-12
  • 2022-01-15
  • 2021-12-01
相关资源
相似解决方案