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
简单的排序题,使用结构体
 #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct Node
{
string No;
int score, final_rank, location_num, local_rank;
}; bool cmp(Node* a, Node* b)
{
return (a->score == b->score) ? (a->No < b->No) : (a->score > b->score);
}
int N, K;
vector<Node*>allPerson;
int main()
{
cin >> N;
for (int i = ; i <= N; ++i)
{
cin >> K;
vector<Node*>temp;
for (int j = ; j < K; ++j)
{
Node* node = new Node;
cin >> node->No >> node->score;
node->location_num = i;
temp.push_back(node);
}
sort(temp.begin(), temp.end(), cmp);
for (int j = ; j < temp.size(); ++j)
{
if (j > && temp[j]->score == temp[j - ]->score)
temp[j]->local_rank = temp[j - ]->local_rank;
else
temp[j]->local_rank = j + ;
}
allPerson.insert(allPerson.end(), temp.begin(), temp.end());
}
sort(allPerson.begin(), allPerson.end(), cmp);
cout << allPerson.size() << endl;
for (int j = ; j < allPerson.size(); ++j)
{
if (j> && allPerson[j]->score == allPerson[j - ]->score)
allPerson[j]->final_rank = allPerson[j - ]->final_rank;
else
allPerson[j]->final_rank = j + ;
cout << allPerson[j]->No << " " << allPerson[j]->final_rank << " " <<
allPerson[j]->location_num << " " << allPerson[j]->local_rank << endl;
}
return ;
}

PAT甲级——A1025 PAT Ranking的更多相关文章

  1. PAT 甲级 1141 PAT Ranking of Institutions

    https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...

  2. PAT 甲级 1025 PAT Ranking

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

  3. PAT甲级——1025 PAT Ranking

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

  4. PAT 甲级 1025.PAT Ranking C++/Java

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

  5. PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)

    题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...

  6. PAT甲级1075 PAT Judge

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032 题意: 有m次OJ提交记录,总共有k道 ...

  7. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  8. PAT甲级——A1075 PAT Judge

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

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

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

随机推荐

  1. C#winfrom listview 设置显示图片

    ListView控件有5种显示图片方式:LargeIcon(大图标),Detail(详细),SmallIcon(小图标),List(列表),Tile,常用前4种.  这里说一下设置方式:LargeIc ...

  2. 第六篇:fastJson常用方法总结

    1.了解json json就是一串字符串 只不过元素会使用特定的符号标注. {} 双括号表示对象 [] 中括号表示数组 "" 双引号内是属性或值 : 冒号表示后者是前者的值(这个值 ...

  3. Win10系统无法安装可选功能提示错误代码0x800F081F的解决方法

    DISM /Online /Cleanup-Image /RestoreHealth /Source:wim:H:\sources\install.wim:1 /limitaccess

  4. 2018-8-10-如何删除错误提交的-git-大文件

    title author date CreateTime categories 如何删除错误提交的 git 大文件 lindexi 2018-08-10 19:16:51 +0800 2018-2-1 ...

  5. Python全栈开发:json与pickle

    #!/usr/bin/env python # -*- coding;utf-8 -*- """ 正解(序列化):将Python数据类型转换成json或者pickle格式 ...

  6. Vim ---- 默认打开行号

    Vim有非常迅速跳转到某一行行首的方法,例如 :n 或者 nG,n 表示到第 n 行. 但是Vim的显示行号功能默认是关闭的. 可用一下方法使Vim默认显示行号: 在配置文件 .vimrc 中,输入 ...

  7. 并发和多线程(二)--启动和中断线程(Interrupt)的正确姿势

    启动线程: 从一个最基本的面试题开始,启动线程到底是start()还是run()? Runnable runnable = () -> System.out.println(Thread.cur ...

  8. Python-进程(1)

    目录 操作系统发展史 穿孔卡片 联机批处理系统 统计批处理系统 单道 多道技术 空间上复用 时间上复用 并行与并发 进程 程序与进程 进程调度 进程的三个状态 就绪态 运行态 阻塞态 同步和异步 阻塞 ...

  9. mysql 一次性插入的数据量过大报错max_allowed_packet解决方法

    查询: show VARIABLES like ‘%max_allowed_packet%‘; 记录下数字(默认是一个7位) 执行语句: ; 重启服务 再查询 该数字 ,如果没变,则修改mysql的m ...

  10. @Component 和 @Bean 的区别

    Spring帮助我们管理Bean分为两个部分,一个是注册Bean,一个装配Bean.完成这两个动作有三种方式,一种是使用自动配置的方式.一种是使用JavaConfig的方式,一种就是使用XML配置的方 ...