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. Spring事物的传播

    spring的事物对于同一个类内部调用是不会生效的. 比如一个ServiceA,里面有个方法x()和y().其中x没有配置事物,而y配置的有实物.如果是一个没有事物的ServiceB调用了Servic ...

  2. 32. 持续集成简介及JDK、Tomcat、Jenkins环境搭建

    持续集成简介 持续集成是一种软件开发实践,即团队开发成员经常集成他们的工作,通常每个成员每天至少集成一次,也就意味着每天可能会发生多次集成.每次集成都通过自动化的构建(包括编译,发布,自动化测试)来验 ...

  3. 力扣算法题—148sort-list

    Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2-> ...

  4. cas4.2.7 集群服务搭建

    cas服务端集群,网上资料很多,无非就是session共享,ticket共享. 但是session共享是必须的吗?或者能实现集群吗? 实践: 1. ticket共享,直接上代码 package org ...

  5. ASE——热身作业自我介绍

    自我介绍 大家好我是王皓,由于之前忙于保研的机试和面试导致第一次作业就拖到第二次写blog的时候才交(非常抱歉..)我喜欢玩CTF,觉得学习安全方向的知识,寻找软件或者硬件的漏洞是一件非常有意义且有趣 ...

  6. 使用vscode搭建本地的websocket

    首先在服务器方面,网上都有不同的对websocket支持的服务器: php - http://code.google.com/p/phpwebsocket/ jetty - http://jetty. ...

  7. Java web 应用自启动 shell脚本自动重启

    之前公司的内部管理系统jenkins自动构建代码有时候会失效,导致服务停掉. 于是乎就搞了一个自动启动脚本. oa.jar就是监测的服务 startup.sh 的内容是运行jar包的命令 java - ...

  8. 为何在新建STM工程中全局声明两个宏

    在uVision中新建STM32工程后,需要从STM32标准库中拷贝标准外设驱动到自己的工程目录中,此时需要在工程设置->C/C++选项卡下的Define文本框中键入这两个全局宏定义. STM3 ...

  9. mongodb的学习 (2)

    1.条件查询 查询姓名为小明的学生                            db.local.find({name:'小明'});; 查询英语成绩大于90分的同学            ...

  10. hdu 3746 kmp的next数组理解

    题目大意: 求最少在结尾补上几个字符才能形成循环 基本思路: next数组有一个性质,长度为len的字符串的最小长度的循环节(可能没有,但有的话一定是)len-next[len],因为最长不能是原串, ...