Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 numbers: N (≤), the total number of students, and K (≤), the total number of courses. Then N lines follow, each contains a student's name (3 capital English letters plus a one-digit number), a positive number C (≤) which is the number of courses that this student has registered, and then followed by C course numbers. For the sake of simplicity, the courses are numbered from 1 to K.

Output Specification:

For each test case, print the student name lists of all the courses in increasing order of the course numbers. For each course, first print in one line the course number and the number of registered students, separated by a space. Then output the students' names in alphabetical order. Each name occupies a line.

Sample Input:

10 5
ZOE1 2 4 5
ANN0 3 5 2 1
BOB5 5 3 4 2 1 5
JOE4 1 2
JAY9 4 1 2 5 4
FRA8 3 4 2 5
DON2 2 4 5
AMY7 1 5
KAT3 3 5 4 2
LOR6 4 2 4 1 5

Sample Output:

1 4
ANN0
BOB5
JAY9
LOR6
2 7
ANN0
BOB5
FRA8
JAY9
JOE4
KAT3
LOR6
3 1
BOB5
4 7
BOB5
DON2
FRA8
JAY9
KAT3
LOR6
ZOE1
5 9
AMY7
ANN0
BOB5
DON2
FRA8
JAY9
KAT3
LOR6
ZOE1
用vec
 #define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int N, K;
vector<string> V[];
bool compare(string& a, string& b)
{
return a < b;
}
int main()
{
scanf("%d%d", &N, &K);
for (int i = ; i < N; i++)
{
char s[];
int C, num;
scanf("%s %d", s,&C);
string name(s);
for (int j = ; j < C; j++)
{
scanf("%d", &num);
V[num].push_back(name);
}
}
for (int i = ; i <= K; i++)
sort(V[i].begin(), V[i].end(), compare);
for (int i = ; i <= K; i++)
{
printf("%d %d\n", i, V[i].size());
for (auto it : V[i])
cout << it<<endl;
}
}
tor就是过不了最后一个测试点

1047 Student List for Course (25分)的更多相关文章

  1. PAT 甲级 1047 Student List for Course (25 分)(cout超时,string scanf printf注意点,字符串哈希反哈希)

    1047 Student List for Course (25 分)   Zhejiang University has 40,000 students and provides 2,500 cou ...

  2. 【PAT甲级】1047 Student List for Course (25 分)

    题意: 输入两个正整数N和K(N<=40000,K<=2500),接下来输入N行,每行包括一个学生的名字和所选课程的门数,接着输入每门所选课程的序号.输出每门课程有多少学生选择并按字典序输 ...

  3. PAT 解题报告 1047. Student List for Course (25)

    1047. Student List for Course (25) Zhejiang University has 40000 students and provides 2500 courses. ...

  4. 1047. Student List for Course (25)

    Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course li ...

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

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  6. PAT甲级题解-1047. Student List for Course (25)-排序

    一开始是建立了course[2501][40001]数组,存储每节课的学生编号然后for循环两层输出,但这样复杂度为O(2500*40000),也很明显导致最后时间超时后来发现最多40000学生,每个 ...

  7. A1047 Student List for Course (25 分)

    一.技术总结 首先题目要看清湖,提出的条件很关键,比如for循环的终止条件,特别注意. 还有这个题目主要考虑到vector的使用,还有注意一定要加上using namespace std; 输出格式, ...

  8. PAT 甲级 1039 Course List for Student (25 分)(字符串哈希,优先队列,没想到是哈希)*

    1039 Course List for Student (25 分)   Zhejiang University has 40000 students and provides 2500 cours ...

  9. PAT 1047 Student List for Course[一般]

    1047 Student List for Course (25 分) Zhejiang University has 40,000 students and provides 2,500 cours ...

随机推荐

  1. DIY 作品 及 维修 不定时更新

    手机电池DIY充电宝 2块,优质手机电池加一个升压ic ,焊上一个 usb 母头.比买的强多了. 还能调压,最高调到24V 可以带白光焊台. 更换手机 SIM/SD 卡二合一 贴上高温胶带,吹下来. ...

  2. R|tableone 快速绘制文章“表一”-基线特征三线表

    首发于“生信补给站” :https://mp.weixin.qq.com/s/LJfgxbTqsp8egnQxEI0nJg 生物医学或其他研究论文中的“表一”多为基线特征的描述性统计.使用R单独进行统 ...

  3. 练习div出现的小问题

    一.出现图片不显示状况1.class中设定的名字不对2.在高单位后面出现了 “:“ 所以也不显示3.上一个div盒子没有写结束标签 4.在添加背景图,把height的值改成auto后不显示,填上具体数 ...

  4. File 关键词

    getParent() 获取父路径 getAbsoluteFile 获取绝对路径 length()  获得文件的字节数 getName() 获取路径中最后部分的名字 getPath() 获取整体路径. ...

  5. asp.net core 3.1 引用的元包dll版本兼容性问题解决方案

    自从.netcore 3.1出来后,大家都想立马升级到最新版本.我也是如此,微软也对.netcore 3.1的官方组件不断升级,几乎每隔几天就会有部分元包可以升级.每次打开Nuget包管理器,“更新” ...

  6. docker redis安装及配置(外网访问 关闭安全限制 设置密码)

    docker run -p 6379:6379 --name redis -v /usr/local/redis/etc/redis.conf:/etc/redis/redis.conf -v /us ...

  7. springboot集成axis1.4

    1.首先通过axis工具根据wsdl文件生成java代码和wsdd文件 set Axis_Lib=/Users/apple/configuration/axis-1_4/lib //lib文件目录se ...

  8. 【攻防世界】simple-unpack

    知识:upx脱壳 simple-unpack 难度系数: 3.0 题目来源: 暂无 题目描述:菜鸡拿到了一个被加壳的二进制文件 提示说有壳子:然后用PE分析发现是ELF upx的壳子

  9. 类与对象 CG作业1. 复数类Comple 。

    问题描述]一个完整的复数由实数部分和序数部分构成,请定义一个复数类,含有两个私有属性realPart和imagPart分别表示复数的实部和虚部,三个成员函数:initComplex实现复数成员变量的初 ...

  10. Python第三章-输入输出和运算符

    输入输出和运算符 一.输入和输出 1.1 输出 `print()`函数用来向终端输出数据(其实也可以向文件输出数据,后面再讲) 可以传递多个参数,则输出的时候 python 会把多个参数的值用空格隔开 ...