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. php 字符串 定界符 json_last_error()

    字符串的3种赋值 1:单引号 $str = '111111111111 '; 2:双引号 $str =" 11111111111 "; 3:定界符 $str = <<& ...

  2. kafka manager遇到的一些问题

    1.启动后第一个报错如下: [error] k.m.a.c.BrokerViewCacheActor - Failed to get broker metrics for BrokerIdentity ...

  3. datetime timestamp使用

    #coding=utf-8 import time import datetime def yes_time(): #获取当前时间 now_time = datetime.datetime.now() ...

  4. Javascript优点和缺点

    优点: 函数是顶级对象 基于原型继承的动态对象 对象字面量和数组字面量 缺点: 全局变量 作用域 自动插入分号 保留字 Unicode typeof parseInt + 浮点数 NaN

  5. WireMock提供Restful接口数据

    1.去官网下载并启动: 2.引入Pom依赖(主要是com.github.tomakehurst:wiremock): <dependency> <groupId>com.git ...

  6. 错误ORA-01110,在已删除数据文件情况下如何删除表空间

    如果先行删除了数据文件,再删除表空间,drop tablespace 会出现如下错误: ORA-01116: error in opening database file 89 ORA-01110: ...

  7. Django有办法打开HTTP长轮询连接吗?

    保持连接打开,直到发生事件. 解决方案 看看Django / Comet(推送):所有邪恶中最少的?或者彗星在Python中的最新推荐? - COMET是“ajax long-polling”的另一个 ...

  8. pytest_参数化之3*3

    import pytesttest_user_data1=[{'user':'linda','password':'888888'}, {'user':'servenruby','password': ...

  9. linux下nano命令大全

    nano是一个字符终端的文本编辑器,有点像DOS下的editor程序.它比vi/vim要简单得多,比较适合Linux初学者使用.某些Linux发行版的默认编辑器就是nano. nano命令可以打开指定 ...

  10. 取消SVN感叹号即去除版本库

    之前不小心直接将版本库 的内容检出 到桌面,后才发现桌面上的文件 都变成了问号,本来也以为没有多大问题,删除 .svn 即可,可是删除所有的.svn后,桌面上还是显示问号,刷新了很多次,还重启电脑 了 ...