#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
const int max_course = 2510;
const int max_stu = 40010;
vector<int> course[max_course];
char name[max_stu][5];
bool cmp(int c1, int c2){
return strcmp(name[c1],name[c2]) < 0;
}
int main(){
int N,K;
int num,class_num;
scanf("%d %d",&N,&K);
for(int i = 0; i < N; i++){
scanf("%s %d",name[i],&num);
for(int j = 0; j < num; j++){
scanf("%d",&class_num);
course[class_num].push_back(i);
}
}
for(int i = 0 ; i < K; i++){
printf("%d %d\n",i+1,course[i+1].size());
sort(course[i+1].begin(),course[i+1].end(),cmp);
for(int j = 0; j < course[i+1].size(); j++){
if ( (i == (K-1)) && (j == (course[i+1].size() - 1))) printf("%s",name[course[i+1][j]]);
else printf("%s\n",name[course[i+1][j]]);
}
}
}
PAT A1047 Student List for Course
最新推荐文章于 2024-08-21 18:53:45 发布