#include #include #include <unordered_map> using namespace std; const int N = 100010; int n, m; vector v[N]; unordered_map<int, int> mp; int main() { cin >> n; for (int i = 0; i < n; i ++ ) { int k, a, b; cin >> k >> a; for (int j = 1; j < k; j ++ ) { cin >> b; v[a].push_back(b); v[b].push_back(a); } } cin >> m; while (m -- ) { int k; cin >> k; mp[k] = 1; } int cnt = 0; for (auto it = mp.begin(); it != mp.end(); it ++ ) { int x = it -> first; if (mp[x] != 0) { mp[x] = 0; bool flag = true; for (int i = 0; i < v[x].size(); i ++ ) { if (mp[v[x][i]] == 1) { flag = false; break; } } if (flag) { printf("%05d", x); cnt ++ ; if (cnt != mp.size()) cout << ' '; } } } if (cnt == 0) puts("No one is handsome"); return 0; } 作者:ChenLiangzhou 链接:https://www.acwing.com/activity/content/code/content/3562175/ 来源:AcWing 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

C++ 找出朋友圈中帅到没有朋友的人

原文地址: https://www.cveoy.top/t/topic/oWW1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录