#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int N=40010;
const int M=26*26*26*10+1;
vector<int> selectCourse[M];
int getID(char name[]){
int id=0;
for(int i=0;i<3;i++){
id=id*26+(name[i]-'A');
}
id=id*10+(name[3]-'0');
return id;
}
int main(){
char name[5];
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<k;i++){
int x,course;
scanf("%d%d",&course,&x);
for(int j=0;j<x;j++){
scanf("%s",name);
int id=getID(name);
selectCourse[id].push_back(course);//注意此处的course
}
}
for(int i=1;i<=n;i++){
char name[5];
scanf("%s",name);
int id=getID(name);
sort(selectCourse[id].begin(),selectCourse[id].end());
printf("%s %d",name,selectCourse[id].size());
for(int j=0;j<selectCourse[id].size();j++){
printf(" %d",selectCourse[id][j]);
}
printf("\n");
}
return 0;
}
A1039
最新推荐文章于 2021-11-06 08:01:09 发布