题源
PTA 乙级
题解
#include<stdio.h>
#include<string.h>
int N,M,n;
int flag = 0;
int student = 0,object = 0;
char key[6][5];
char own[5];
char name[5];
int main(){
scanf("%d %d",&N,&M);
int i = 0,j = 0;
for(i = 0;i < M;i++)scanf("%s",&key[i]);
for(i = 0;i < N;i++){
scanf("%s %d",&name,&n);
for(flag = 0;n--;){
scanf("%s",&own);
for(j = 0;j < M;j++){
if(strcmp(own,key[j])==0){
if(flag==0){
printf("%s:",name);
student++;flag++;
}
printf(" %s",own);
object++;
}
}
}if(flag!=0)printf("\n");
}
printf("%d %d\n",student,object);
getchar();getchar();
return 0;
}