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. 指向自身类型的成员指针的初始化,this不属于类对象的一部分

    有下面的一个简单的类: class CNullPointCall{public:    static void Test1();    void Test2();    void Test3(int  ...

  2. 抓包工具tcpdump用法说明--1

    本文目录: 1.1 tcpdump选项 1.2 tcpdump表达式 1.3 tcpdump示例 tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项 ...

  3. Java关于Math类的三个取整方法

    0x01 在java的Math类中有三个关于浮点数取整数的方法,分别是ceil (向上取整) floor(向下取整) round(四舍五入) 三个方法 0x02 ceil 向上取整,取整后总是比原来的 ...

  4. linux命令行光标移动技巧

    看一个真正的专家操作命令行绝对是一种很好的体验-光标在单词之间来回穿梭,命令行不同的滚动.在这里强烈建立适应GUI节目的开发者尝试一下在提示符下面工作.但是事情也不是那么简单,还是需要知道“如何去做” ...

  5. ng -v 不是内部或外部命令

    输入 npm install -g @angular/cli ng new my-app 提示ng -v 不是内部或外部命令 解决方法 1.安装过程中是否出错 原因可能是npm install -g  ...

  6. 5. 使用grafana模板

    我们刚刚配置的Dashboard还是有点简陋,为了界面美观,这里我们这里使用一些模板 1.使用node_exporter模板 去grafana官网下载模板,点击Download,如下所示 2.导入模板 ...

  7. haproxy附加

    1.安装haproxy yum -y install haproxy 2.编写文件  vim /etc/haproxy/haproxy.cfg

  8. 20140923 cin.get() getline cin

    #include<iostream> #include<string> using namespace std; int main() {     string title; ...

  9. 从输入url到显示网页,发生了那些事情?

    作为一个软件开发者,你一定会对网络应用如何工作有一个完整的层次化的认知,同样这里也包括这些应用所用到的技术:像浏览器,HTTP,HTML,网络服务器,需求处理等等. 本文将更深入的研究当你输入一个网址 ...

  10. 神奇,教你用随机数打印hello world

    下面是一段随机数程序. public static void main(String[] args) { System.out.println(randomString(-229985452) + & ...