PAT (Advanced Level) 1025. PAT Ranking (25)
简单题。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string>
#include<vector>
using namespace std; const int maxn=;
int n,tot=;
int sz[maxn];
struct X
{
string id;
int c;
int ans1,ans2,ans3;
}s[+]; bool cmp(const X&a,const X&b)
{
return a.c>b.c;
} bool cmp1(const X&a,const X&b)
{
if(a.ans1==b.ans1) return a.id<b.id;
return a.ans1<b.ans1;
} int main()
{
scanf("%d",&n); int sum=;
for(int i=;i<=n;i++)
{
scanf("%d",&sz[i]);
for(int j=;j<=sz[i];j++)
{
++tot;
cin>>s[tot].id;
cin>>s[tot].c;
s[tot].ans2=i;
}
sort(s+sum+,s++tot,cmp);
s[sum+].ans3=;
for(int i=sum+;i<=tot;i++)
{
if(s[i].c==s[i-].c) s[i].ans3=s[i-].ans3;
else s[i].ans3=i-sum;
}
sum=tot;
}
sort(s+,s+tot+,cmp);
s[].ans1=;
for(int i=;i<=tot;i++)
{
if(s[i].c==s[i-].c) s[i].ans1=s[i-].ans1;
else s[i].ans1=i;
}
sort(s+,s+tot+,cmp1); printf("%d\n",tot);
for(int i=;i<=tot;i++)
{
cout<<s[i].id;
printf(" %d %d %d\n",s[i].ans1,s[i].ans2,s[i].ans3);
}
return ;
}
PAT (Advanced Level) 1025. PAT Ranking (25)的更多相关文章
- PTA(Advanced Level)1025.PAT Ranking
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- PAT (Advanced Level) 1114. Family Property (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT (Advanced Level) 1109. Group Photo (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- PAT (Advanced Level) 1105. Spiral Matrix (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...
- PAT (Advanced Level) 1101. Quick Sort (25)
树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...
- PAT (Advanced Level) 1075. PAT Judge (25)
简单模拟题. 注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名. 如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分. #include<cstd ...
- PAT (Advanced Level) 1071. Speech Patterns (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1063. Set Similarity (25)
读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...
- PAT (Advanced Level) 1059. Prime Factors (25)
素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
随机推荐
- PHP:preg_replace
关于preg_match: http://www.cnblogs.com/helww/p/3466720.html 关于preg_match_all:暂时没有完整的 preg_replace_call ...
- windows7安装oracle 10g
1.出现如下错误 解决办法: ①确保你有该文件夹的完全控制权.文件夹点右键->属性->安全->高级->所有者->改为自己->编辑自己的权限为完全控制. ②将setu ...
- ckediter
ckediter ##<link rel='stylesheet' href='/css/index.css' /> <script type="text/javascri ...
- Java 类的加载过程(阿里面试题)
问以下程序打印出什么内容: 问题及解析如下: /** * 加载方法不等于执行方法,初始化变量则会赋值 * 类加载顺序应为 加载静态方法-初始化静态变量-执行静态代码块 * 实例化时 先加载非静态方法- ...
- Mysql-左连接查询条件失效的解决办法
on 后面不能 接and 要接where 这个条件才能判断成功 判断条件先后顺序,先判断主条件where,再判断条件on 如果是左连接on限制的就是右表,如果不为真则那一行的值为null,where限 ...
- SCP测试服务器的上行/下行带宽
SCP测试服务器的上行/下行带宽,这个咋弄呢?有时间再研究一下.
- Hibernate 系列教程17-查询缓存
在二级缓存配置成功的基础上进行查询缓存配置 Product public class Product { private Long id; private String name; Product.h ...
- Hibernate 系列教程7-双向一对一
双向一对一 一对一主要用在 一个一方需要的信息比较少,比如注册的登录信息 另一个一方存储的信息比较多,比如注册之后用户填写的详细信息 实现方式常用的主要有2种: java模型都是一样,其中一个映射文件 ...
- HDU 2018 undefined
题目思路:完全背包,dp[i][j]代表,砍j只怪,用i点疲劳最多能获得的经验值. 和平常的完全背包不一样的是多了一个限制条件:最多只砍S只怪,所以我们应该多一重循环来q:for 1->S,代表 ...
- iOS 枚举写法
1.第一种 typedef enum { kPRStateNormal = 0, kPRStatePulling = 1, kPRStateLoading = 2, kPRStateHitTheEnd ...