正确代码
#include "head.h"
//int M;scanf("%d\n",&M);printf("Keep going...");
int main()
{
//freopen("D:\\文件夹\\Desktop\\use.txt","r",stdin);
int N,M;scanf("%d %d\n",&N,&M);
map<int,int> mp;
map<int,int> ::iterator it;
int people = 0,thing = 0; //违禁人数,违禁物品数
for(int i = 0;i < M;++i){
int p;scanf("%d",&p);
mp[p] = i;}
getchar();
for(int i = 0;i < N;++i){
char name[5];int thingnum;
scanf("%s %d",name,&thingnum);
int thispeople = 0; //这个人的违禁物
int thisflag = 0; //这个人是否违禁
for(int j = 0;j < thingnum;++j){
int num;scanf("%d",&num);
it = mp.find(num);
if(it != mp.end()){
if(people != 0 && thispeople == 0) printf("\n"); //所有违禁人数
if(thispeople == 0) printf("%s:",name);
printf(" %04d",num);
thispeople++;
thisflag = 1;}
}
if(thisflag == 1) people++;
thing += thispeople;}
if(people != 0) printf("\n");
printf("%d %d",people,thing);
return 0;
}
一个小小的注意事项,printf(" %04d",num),你看看这个04,是不是你苦苦追寻的那个测试点2