#include<bits/stdc++.h>
using namespace std;
struct node
{
char name[15];
struct node *next;
};
struct node *nlist[2010];
int slist[2010];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
memset(slist,0,sizeof(slist));
for(int i=0; i<2010; i++)
{
nlist[i]=(struct node*)malloc(sizeof(struct node));
nlist[i]->next=NULL;
}
for(int i=0; i<n; i++)
{
char name0[15];
int sclass;
scanf("%s%d",name0,&sclass);
while(sclass--)
{
int t;
scanf("%d",&t);
slist[t]++;
struct node *q=(struct node*)malloc(sizeof(struct node));
q->next=NULL;
strcpy(q->name,name0);
struct node *p=nlist[t];
while(p->next)
{
if(strcmp(q->name,p->next->name)<0)
break;
p=p->next;
}
q->next=p->next;
p->next=q;
}
}
for(int i=1; i<=m; i++)
{
printf("%d %d\n",i,slist[i]++);
struct node *j=nlist[i]->next;
while(j)
{
printf("%s\n",j->name);
j=j->next;
}
}
}
}
SDUT3404数据结构实验之排序七:选课名单
最新推荐文章于 2019-07-24 08:45:28 发布