#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
const int N = 40010;
const int M=2510;
char name[N][5];
vector<int> course[M];
typedef long long ll;
bool cmp(int a,int b){
return strcmp(name[a],name[b])<0;
}
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif // LOCAL
int n,k,c,courseID;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++){
scanf("%s%d",name[i],&c);
for(int j=0;j<c;j++){
scanf("%d",&courseID);
course[courseID].push_back(i);
}
}
for(int i=1;i<=k;i++){
printf("%d %d\n",i,course[i].size());
sort(course[i].begin(),course[i].end(),cmp);
for(int j=0;j<course[i].size();j++){
printf("%s\n",name[course[i][j]]);
}
}
return 0;
}
【PAT】1047. Student List for Course
最新推荐文章于 2023-03-14 20:07:32 发布