简单题。

#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)的更多相关文章

  1. PTA(Advanced Level)1025.PAT Ranking

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  2. PAT (Advanced Level) 1114. Family Property (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  3. PAT (Advanced Level) 1109. Group Photo (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  4. PAT (Advanced Level) 1105. Spiral Matrix (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...

  5. PAT (Advanced Level) 1101. Quick Sort (25)

    树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...

  6. PAT (Advanced Level) 1075. PAT Judge (25)

    简单模拟题. 注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名. 如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分. #include<cstd ...

  7. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  8. PAT (Advanced Level) 1063. Set Similarity (25)

    读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...

  9. PAT (Advanced Level) 1059. Prime Factors (25)

    素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...

随机推荐

  1. shell:crontab

    crontab */1 * * * * (cd /home/q/system/project; /usr/bin/lockf -t 0 /tmp/discuz_bbs_audit.lock /usr/ ...

  2. HttpRequest中常见的四种ContentType【转载】

    本文转自:http://www.aikaiyuan.com/6324.html HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.T ...

  3. mongodb移除分片

    MongoDB的Shard集群来说,添加一个分片很简单,AddShard就可以了. 但是缩减集群(删除分片)这种一般很少用到.由于曙光的某服务器又挂了,所以我们送修之前必须把它上面的数据自动迁移到其他 ...

  4. 转换流--InputStreamReader ,OutputStreamWriter

    BufferedReader 字符流,只能装饰字符流,不能装饰字节流.有个重要且好用的方法是readLine()整行读取字符. 但是InputStream是字节流,没有resdLine方法,那么字节流 ...

  5. 青蛙的约会<数论,extgcd>

    青蛙的约会 题意: 在一个圆上有一个零刻度点,公青蛙和母青蛙分别在A点和B点<不同的位 置>,他们每秒行走的距离分别是m和n,圆的周长是L.问题是这两个青 蛙能不能相遇,若能在什么时候相遇 ...

  6. [转]java static final 初始化

    http://tanbing1986411.blog.163.com/blog/static/7259798220103610224434/ java static final 初始化 1.stati ...

  7. SAX,DOM,JAXP,JDOM,DOM4J比较

    dom,sax,jdom,dom4j的技术特点: 1: DOMDOM 是用与平台和语言无关的方式表示 XML 文档的官方 W3C 标准.DOM 是以层次结构组织的节点或信息片断的集合.这个层次结构允许 ...

  8. Java 多态,重载,重写

    1.多态(polymorphism): 多态是指程序中定义的引用变量所指向的具体类型和通过该引用变量发出的方法调用在编程时并不确定,而是在程序运行期间才确定,即一个引用变量倒底会指向哪个类的实例对象, ...

  9. AS-->如何更高效的使用 Gradle, 快速build apk

    版权声明:欢迎转载,转载请注明出处;http://blog.csdn.net/angcyo 看本文之前,推荐先看我之前写的一篇文章: 传送门 日前Android Stuido 已经更新到 2.0.0 ...

  10. strut1.X和spring整合的二种方法

    第一种集成方法 原理:在Action中取得BeanFactory对象,然后通过BeanFactory获取业务逻辑对象 缺点:产生了依赖,spring的类在action中产生了依赖查找.(注意和依赖注入 ...