solution
测试点2:物品编号可能不足四位,高位需补0
#include<iostream>
#include<string>
using namespace std;
const int maxn = 1e5;
int flag[maxn] = {0};
int main(){
int n, m, k, cnt = 0, cnt1 = 0, have, x;
string id;
cin >> n >> m;
for(int i = 0; i < m; i++){
cin >> x;
flag[x] = 1;
}
for(int i = 0; i < n; i++){
have = 0;
int goods[15];
cin >> id >> k;
for(int j = 0; j < k; j++){
cin >> goods[j];
if(flag[goods[j]]) {
have = 1;
cnt++;
}
}
if(have){
cnt1++;
cout << id << ":";
for(int j = 0; j < k; j++){
if(flag[goods[j]]) printf(" %04d", goods[j]);
}
cout << endl;
}
}
cout << cnt1 << " " << cnt;
return 0;
}