#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
const int maxn=1e5+10;
struct stu{
char name[5];
};
bool cmp(stu a,stu b){
return strcmp(a.name,b.name)<0;
}
int n,k;
int main(){
// freopen("E://PAT/input.txt", "r", stdin);
scanf("%d %d",&n,&k);
vector<stu> co[k+1];
stu s;
for(int i=1;i<=n;i++){
scanf("%s",s.name);
int c;
scanf("%d",&c);
while(c--){
int tmp;
scanf("%d",&tmp);
co[tmp].push_back(s);
}
}
for(int i=1;i<=k;i++){
printf("%d %d\n",i,co[i].size());
sort(co[i].begin(),co[i].end(),cmp);
for(int j=0;j<co[i].size();j++)
printf("%s\n",co[i][j].name);
}
return 0;
}
1047. Student List for Course (25)
最新推荐文章于 2022-02-16 14:52:49 发布
本文提供了一道PAT竞赛中的C++编程题目的详细解答过程,该题目涉及到学生信息的输入、存储及按姓名排序输出等功能。通过使用C++标准库中的数据结构如vector和结构体,以及自定义排序函数,实现了对学生信息的有效管理和展示。

1553

被折叠的 条评论
为什么被折叠?



