https://pintia.cn/problem-sets/994805260223102976/problems/994805263964422144
测试点2是要以4位数字的格式输出。这么简单的点居然给忘了!
#include<iostream>
using namespace std;
int main() {
int n, m, t, w, temp, k, item[10000]={0}, weijin[6], count1=0, count2=0;
cin >> n >> m;
string name;
for(int i=0; i<m; i++){
cin >> t;
item[t] = 1;
}
for(int i=0; i<n; i++){
k = 0;
cin >> name >> w;
for(int j=0; j<w; j++){
cin >> temp;
if(item[temp]==1){
weijin[k]=temp;
k ++;
}
}
if(k>0){
count1 ++;
cout << name << ": ";
}
for(int j=0; j<k; j++){
count2 ++;
printf("%04d", weijin[j]);
if(j<k-1){
cout << " ";
}else{
cout << endl;
}
}
}
cout << count1 << " " << count2 << endl;
return 0;
}