1047. Student List for Course (25)
来源:互联网 发布:matlab求解最优化问题 编辑:程序博客网 时间:2024/06/06 05:28
保存输入结果,按名字排序,再输出到结果集中
#include<iostream>#include<vector>#include<algorithm>#include<string>#pragma warning(disable:4996)using namespace std;struct student { string name; vector<int> subject; bool operator<(const student that) { return this->name < that.name; }};int N, M;vector<student> ccin;//存储输入数据vector<vector<string>> sub;//存储结果int main(){ cin >> N >> M; ccin.resize(N); sub.resize(M); for (int t = 0;t < N;t++) { char a[5]; int temp; scanf("%s %d", a, &temp); ccin[t].name = a; ccin[t].subject.resize(temp); for (int i = 0;i < temp;i++) scanf("%d", &ccin[t].subject[i]); } sort(ccin.begin(), ccin.end()); for (auto x : ccin) { for (auto y : x.subject) sub[y - 1].push_back(x.name); } int n = 1; for (auto x : sub) { printf("%d %d\n", n++, x.size()); for (auto y : x) printf("%s\n", y.c_str()); }}
0 0
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)-PAT
- 1047. Student List for Course (25)
- 【PAT】1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- PAT 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- PAT 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- 1047. Student List for Course (25)
- Overload和Override的区别
- 图片链接,没什么用\(^o^)/
- Android CountDownTimer学习使用
- Android输入法弹出,布局上移,背景不会压缩
- threejs相机和渲染器
- 1047. Student List for Course (25)
- 使用Vue.js过程中,踩过的坑
- Java学习笔记
- 加密
- 算典03_习题_06_POJ-1888
- leecode 解题总结:100. Same Tree
- python 爬虫初识 ,不断更新中
- C语言程序设计经典50例
- 每天一个linux命令:netstat命令