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 ;
}
PAT (Advanced Level) 1047. Student List for Course (25)的更多相关文章
- PAT 解题报告 1047. Student List for Course (25)
1047. Student List for Course (25) Zhejiang University has 40000 students and provides 2500 courses. ...
- PAT (Advanced Level) Practise - 1094. The Largest Generation (25)
http://www.patest.cn/contests/pat-a-practise/1094 A family hierarchy is usually presented by a pedig ...
- PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)
This time you are asked to tell the difference between the lowest grade of all the male students and ...
- PAT (Advanced Level) 1102. Invert a Binary Tree (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1098. Insertion or Heap Sort (25)
简单题.判断一下是插排还是堆排. #include<cstdio> #include<cstring> #include<cmath> #include<ve ...
- PAT (Advanced Level) 1067. Sort with Swap(0,*) (25)
只对没有归位的数进行交换. 分两种情况: 如果0在最前面,那么随便拿一个没有归位的数和0交换位置. 如果0不在最前面,那么必然可以归位一个数字,将那个数字归位. 这样模拟一下即可. #include& ...
- PAT (Advanced Level) 1066. Root of AVL Tree (25)
AVL树的旋转.居然1A了.... 了解旋转方式之后,数据较小可以当做模拟写. #include<cstdio> #include<cstring> #include<c ...
- PAT (Advanced Level) 1055. The World's Richest (25)
排序.随便加点优化就能过. #include<iostream> #include<cstring> #include<cmath> #include<alg ...
- PAT (Advanced Level) 1082. Read Number in Chinese (25)
模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
随机推荐
- 《Java Mail》
<Java Mail> 文/冯皓林 完稿:2016.3.16--2016.3.19 “特定环境.一类问题.N个解决方案” 一.RFC821文档说明 核心: 邮件(Mail): 1.邮件头( ...
- 第二十节,基本数据类型,集合set、综合应用新数据更新老数据
基本数据类型,集合set.综合应用新数据更新老数据 创建两个字典新数据,更新原始数据,a为原始数据,b为新数据 1,分别获取到a字典和b字典的key(键),将两个字典的键分别转换成两个集合 2,找出a ...
- elasticsearch简介
elasticsearch 摘要: 1 es是一个分布式全文搜索引擎.特定是:无中心化,实时,扩展性强. 2. es有几个好的概念或者特点:(1)cluster 集群无中心化.(2)shards.分片 ...
- while;do while;switch;break;continue
1.while: 格式:while(判断条件) { 满足条件要执行的语句 } while语句与for语句对比(小九九) 1.1 for <script>for (var i= ...
- differences between null pointer and void pointer.
These are two different concepts, you cannot compare them. What the difference between the skunk and ...
- 被非技术瓶颈阻挡了,没钱买Mac,挣扎ing
最近一直没来写博客,因为一直在找刷盘子.服务生.看店的工. 已经找到,主要因为前阵子天不热,所以酒馆的顾客不多.现在好了. 只好买个Mac mini,看了很多帖子,也只好暂时折中这样了.Mac买不起. ...
- Ansible3:ansible.cfg配置说明【转】
Ansible默认安装好后有一个配置文件/etc/ansible/ansible.cfg,该配置文件中定义了ansible的主机的默认配置部分,如默认是否需要输入密码.是否开启sudo认证.actio ...
- 笨方法学python--安装和准备
1 下载并安装python http://python.org/download 下载python2.7. python2.7并不是python3.5的旧版本. python2现在应用较广,网上资料较 ...
- String 转Map(基于Guava类库)
字符串格式:key1=value1&key2=value2...... java代码 Map<String,String> targetOrderObj = Splitter.on ...
- OpenGL编程指南第版本学习笔记 --- OpenGL程序实现过程(win32 + OpenGL)
1. 先上代码 头文件glCommon.h #include <GL/glew.h> #include <GL/GL.h> #include <GL/GLU.h> ...