Source:

PAT A1025 PAT Ranking

Description:

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge all the ranklists and generate the final rank.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive number N (≤), the number of test locations. Then N ranklists follow, each starts with a line containing a positive integer K (≤), the number of testees, and then K lines containing the registration number (a 13-digit number) and the total score of each testee. All the numbers in a line are separated by a space.

Output Specification:

For each test case, first print in one line the total number of testees. Then print the final ranklist in the following format:

registration_number final_rank location_number local_rank

The locations are numbered from 1 to N. The output must be sorted in nondecreasing order of the final ranks. The testees with the same score must have the same rank, and the output must be sorted in nondecreasing order of their registration numbers.

Sample Input:

2
5
1234567890001 95
1234567890005 100
1234567890003 95
1234567890002 77
1234567890004 85
4
1234567890013 65
1234567890011 25
1234567890014 100
1234567890012 85

Sample Output:

9
1234567890005 1 1 1
1234567890014 1 2 1
1234567890001 3 1 2
1234567890003 3 1 2
1234567890004 5 1 4
1234567890012 5 2 2
1234567890002 7 1 5
1234567890013 8 2 3
1234567890011 9 2 4

Keys:

  • 模拟题

Code:

 /*
Data: 2019-07-17 18:57:55
Problem: PAT_A1025#PAT Ranking
AC: 18:58 题目大意:
排序
输入:
第一行给出,考场数N<=100
接下来N个列表
第一行给出,考生数K<=300
接下来K行,id,score
输出:
考生总数
id,总排名,考场号,考场名次(总排名递增+id递增)
*/
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
string id;
int score;
int ln,lr;
}temp;
vector<node> fin; bool cmp(const node &a, const node &b)
{
if(a.score != b.score)
return a.score > b.score;
else
return a.id < b.id;
} int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif int n,k;
scanf("%d", &n);
for(int i=; i<=n; i++)
{
scanf("%d", &k);
vector<node> loc;
for(int j=; j<k; j++)
{
cin >> temp.id >> temp.score;
temp.ln = i;
loc.push_back(temp);
}
sort(loc.begin(),loc.end(),cmp);
int r=;
for(int j=; j<k; j++)
{
if(j== || loc[j-].score!=loc[j].score)
r = j+;
loc[j].lr = r;
fin.push_back(loc[j]);
}
}
sort(fin.begin(),fin.end(),cmp);
printf("%d\n", fin.size());
int r=;
for(int i=; i<fin.size(); i++)
{
if(i== || fin[i-].score!=fin[i].score)
r=i+;
cout << fin[i].id;
printf(" %d %d %d\n", r,fin[i].ln,fin[i].lr);
} return ;
}

PAT_A1025#PAT Ranking的更多相关文章

  1. PAT Ranking (排名)

    PAT Ranking (排名) Programming Ability Test (PAT) is organized by the College of Computer Science and ...

  2. 1025 PAT Ranking[排序][一般]

    1025 PAT Ranking (25)(25 分) Programming Ability Test (PAT) is organized by the College of Computer S ...

  3. PAT 甲级 1025 PAT Ranking

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  4. 1141 PAT Ranking of Institutions[难]

    1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of ...

  5. pat1025. PAT Ranking (25)

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  6. A1025 PAT Ranking (25)(25 分)

    A1025 PAT Ranking (25)(25 分) Programming Ability Test (PAT) is organized by the College of Computer ...

  7. PAT_A1141#PAT Ranking of Institutions

    Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center wil ...

  8. 1025 PAT Ranking (25分)

    1025 PAT Ranking (25分) 1. 题目 2. 思路 设置结构体, 先对每一个local排序,再整合后排序 3. 注意点 整体排序时注意如果分数相同的情况下还要按照编号排序 4. 代码 ...

  9. PAT甲级——1025 PAT Ranking

    1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...

随机推荐

  1. java == 和equals()

    == == 是运算符 :可以使用在基本数据类型变量和引用数据类型变量当中 : 如果比较的是基本数据类型变量,比较两个变量保存的数据是否相等(不一定类型相同) 如果比较的是引用数据类型变量, 比较两个对 ...

  2. winform中的小技巧【自用】

    一.C#在WinForm中怎样让多行TEXTBOX的换行 今天做项目,有一段提示文字需要弹出来,由于太长,我就想能不能让它换行.然后就百度了一下,嘿嘿,方法很好用哦. 原文链接:https://blo ...

  3. 2019山东省ACM省赛菜鸡的赛后总结

    省赛总结 2019-05-13 21:27:40 虽然第一次就死的这么难看,但是的确发现了很多问题,我想这是未来我和我的队友要解决的,而不是去难过,去感慨自己是有多菜.在大一训练结束马上参加暑假集训的 ...

  4. 【JavaSE】运行时类型信息(RTTI、反射)

    运行时类型信息使得你可以在程序运行时发现和使用类型信息.--<Think in java 4th> **** 通常我们在面向对象的程序设计中我们经常使用多态特性使得大部分代码尽可能地少了解 ...

  5. 以您熟悉的编程语言为例完成一个hello/hi的简单的网络聊天程序

    Socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟机或不同计算机之间的通信,应用程序通常通过"套接字"向网络发出 ...

  6. 洛谷 P2024 [NOI2001]食物链——带权值的并查集维护

    先上一波题目 https://www.luogu.org/problem/P2024 通过这道题复习了一波并查集,学习了一波带权值操作 首先我们观察到 所有的环都是以A->B->C-> ...

  7. Tomcat发布项目的几种方式

    如何在浏览器访问一个xml文件 拷贝这个文件到webapps/ROOT底下, 在浏览器里面访问 直接把tomcat/webapps/ROOT目录下 浏览器访问http://localhost:8080 ...

  8. MyBatis笔记二:配置

    MyBatis笔记二:配置 1.全局配置 1.properites 这个配置主要是引入我们的 properites 配置文件的: <properties resource="db.pr ...

  9. 每天一个Linux常用命令 ls命令

    ls:列出目录中的内容 -l  显示详细信息 -a 显示所有文件,包括隐藏文件 -i  显示inode -t :依时间排序,而不是用档名. -r :将排序结果反向输出,例如:原本档名由小到大,反向则为 ...

  10. 了解跨站请求伪造CSRF

    参考以下两篇文章: https://www.cnblogs.com/Erik_Xu/p/5481441.html https://www.cnblogs.com/4littleProgrammer/p ...