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. 正则表达式r和re

    # coding:utf-8 import re print 'a\ws' print r'a\nb' # r'': 一般用在正则表达式中,称为原始字符串,作用是将Python语法中的反斜杠转义给 取 ...

  2. day 65 Django基础之django分页

      Django基础之django分页   一.Django的内置分页器(paginator) view from django.shortcuts import render,HttpRespons ...

  3. demjson处理json数据

    因为json数据不规范出现了以下问题: json.decoder.JSONDecodeError: Expecting property name enclosed in double quo 网上查 ...

  4. docker 个人遇到问题日志记录

    system: openSUSE Leap 42.3 在openSUSE中可直接运行" sudo zypper in docker"进行安装docker-ce wakasann@l ...

  5. MySQL中\g和\G的作用

    \g的作用和MySQL中的分号”;"是一样: \G的作用是讲查找到的内容结构旋转90度,变成纵向结构: 下面举例说明,查找数据库中的存在的存储过程状态: SHOW PROCEDURE STA ...

  6. 在github上怎样克隆vue项目及运行

    长时间不做vue项目,今天看vue项目运行时有些指令忘记了,在这里写下相关指令 .克隆已有项目,一般情况项目中的README.md写的是项目运行步骤,一般项目的运行如下 克隆项目 git clone ...

  7. [转]Hessian——轻量级远程调用方案

    Hessian是caucho公司开发的一种基于二进制RPC协议(Remote Procedure Call protocol)的轻量级远程调用框架.具有多种语言的实现,但用的最多的当然是Java实现 ...

  8. thinkphp 区间查询

    ThinkPHP支持对某个字段的区间查询,例如: 富瑞华大理石平台厂家哪家好 $map['id'] = array(array('gt',1),array('lt',10)) ; 得到的查询条件是:  ...

  9. 模拟+贪心——cf1131E

    超级恶心的题,写了好久,直接倒序模拟做,但是网上有博客好像是直接正序dp做的.. 因为左端点和右端点是永远不会变的,然后情况要考虑全 /* 从后往前插 只要记录左连续,右连续,中间连续 左端点一定是L ...

  10. 小程序关闭时暂停webview里的音乐

    document.addEventListener("visibilitychange", () => {  if(document.hidden) {     // 页面被 ...