PAT (Advanced Level) 1047. Student List for Course (25)

简单题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std; const int maxn=+; struct X
{
char name[];
vector<int>v;
}s[maxn]; struct Ans
{
vector<int>v;
}ans[maxn]; bool cmp1(const X&a,const X&b)
{
return strcmp(a.name,b.name)<;
} int n,m; int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%s",s[i].name);
int num; scanf("%d",&num);
while(num--)
{
int id; scanf("%d",&id);
s[i].v.push_back(id);
}
} sort(s+,s++n,cmp1); for(int i=;i<=n;i++)
for(int j=;j<s[i].v.size();j++)
ans[s[i].v[j]].v.push_back(i); for(int i=;i<=m;i++)
{
printf("%d %d\n",i,ans[i].v.size());
for(int j=;j<ans[i].v.size();j++)
printf("%s\n",s[ans[i].v[j]].name);
}
return ;
}
上一篇:在VMware上安装VMTools


下一篇:PAT 解题报告 1050. String Subtraction (20)