题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805263964422144
基本一遍过,注意if里面双等号不要漏打一个等号
代码
#include<cstdio>#include<iostream>#include<string>#include<vector>#include<map>using namespace std;map<int ,int> ban_list;map<string, bool> per_list;int main(){int n, m, k, temp_int, count1 = 0;scanf("%d%d", &n, &m);string temp_str;for(int i = 0; i < m; i++){scanf("%d", &k);ban_list[k]++;}for(int i = 0; i < n; i++){cin>>temp_str>>k;int flag = 0;per_list[temp_str] = false;for(int j = 0; j < k; j++){scanf("%d" ,&temp_int);if(ban_list[temp_int] != 0){if(flag == 0){flag = 1;cout<<temp_str + ":";}printf(" %04d", temp_int);per_list[temp_str] = true;count1 ++;}}if(flag == 1)printf("\n");}int count2 = 0;for(auto it = per_list.begin(); it != per_list.end(); it++){if(it->second) count2++;}printf("%d %d", count2, count1);}
