Skip to content

Instantly share code, notes, and snippets.

@Ionizing
Last active November 9, 2017 14:38
Show Gist options
  • Save Ionizing/dd8b4643833d28982a685ee6cae930d1 to your computer and use it in GitHub Desktop.
Save Ionizing/dd8b4643833d28982a685ee6cae930d1 to your computer and use it in GitHub Desktop.
/*
https://www.patest.cn/contests/pat-b-practise/1072
*/
#include <iostream>
#include <set>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
struct BStu
{
std::string Name = "";
std::vector<int> BItems;
};
int main(){
int N, M;
cin >> N >> M;
std::set<int> Banned_items;
for(int i=0; i!=M; ++i){
int tmp;
cin >> tmp;
Banned_items.insert(tmp);
}
std::string name;
int item_num(0);
std::vector<struct BStu> BStu_list;
int BStu_num(0), BItem_num(0);
for(int i=0; i!=N; ++i){
cin >> name;
cin >> item_num;
struct BStu tmp;
for(int j=0, item(0); j!=item_num; ++j){
cin >> item;
if(Banned_items.find(item) != Banned_items.end()) {
tmp.BItems.push_back(item);
}
}
if(!tmp.BItems.empty()){
tmp.Name = name;
BStu_list.push_back(tmp);
++BStu_num;
BItem_num += tmp.BItems.size();
}
}
int List_size = BStu_list.size();
for(int i=0; i!=List_size; ++i){
cout << BStu_list[i].Name << ":";
for(int j=0; j!=BStu_list[i].BItems.size(); ++j){
cout << " " << BStu_list[i].BItems[j];
}
cout << endl;
}
cout << BStu_num << " " << BItem_num << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment