PAT 甲级 1025 PAT Ranking
1025. PAT Ranking (25)
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 (<=100), the number of test locations. Then N ranklists follow, each starts with a line containing a positive integer K (<=300), 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 <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <map>
#include <string> using namespace std;
typedef long long int LL;
int n,k;
struct Node
{
string num;
int r1;
int tag;
int score;
}a[100005];
int cmp(Node a,Node b)
{
if(a.score==b.score)
return a.num<b.num;
return a.score>b.score;
}
map<string,int> m;
int main()
{
scanf("%d",&n);
int cnt=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&k);
int l=cnt;
//m.clear();
for(int j=1;j<=k;j++)
{
cin>>a[cnt].num;
scanf("%d",&a[cnt].score);
a[cnt++].tag=i;
}
sort(a+l,a+l+k,cmp);
int r=0;
for(int j=l;j<cnt;j++)
{
r++;
if(j!=l&&a[j].score==a[j-1].score)
m[a[j].num]=m[a[j-1].num];
else if(j==l||a[j].score!=a[j-1].score)
m[a[j].num]=r;
}
}
sort(a,a+cnt,cmp);
int r=0;
printf("%d\n",cnt);
for(int i=0;i<cnt;i++)
{
cout<<a[i].num<<" ";
r++;
if(i!=0&&a[i].score==a[i-1].score) a[i].r1=a[i-1].r1;
else if(i==0||a[i].score!=a[i-1].score)
a[i].r1=r; printf("%d %d %d\n",a[i].r1,a[i].tag,m[a[i].num]);
}
return 0;
}
PAT 甲级 1025 PAT Ranking的更多相关文章
- PAT甲级——1025 PAT Ranking
1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...
- PAT 甲级 1025.PAT Ranking C++/Java
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...
- PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)
题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...
- 【PAT】1025. PAT Ranking (25)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1025 题目描述: Programming Ability Test (PAT) is orga ...
- PAT 甲级 1141 PAT Ranking of Institutions
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...
- PAT甲级——A1025 PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...
- PAT甲级1075 PAT Judge
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032 题意: 有m次OJ提交记录,总共有k道 ...
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT甲级——A1075 PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
随机推荐
- vector常见用法
#include <boost/foreach.hpp> #include <iostream> #include <vector> #include <bo ...
- jquery经常使用操作
页面load方法 $().ready(function() { }) div隐藏操作 // div是否隐藏 function isHideMenu(){ return $("#menuCon ...
- error: invalid use of incomplete type
一般出现这种情况都是没有将用到的头文件包含进来 我的情况是在头文件中定义了一个QMenu的指针,在源文件中使用menuBar()函数来返回一个menu指针.我在源文件中包含了文件<QtGui&g ...
- Python3制作中文词云图
1. 准备好文本数据 2. pip install jieba 3. pip install wordcloud 4. 下载字体例如Songti.ttc(mac系统下的称呼,并将字体放在项目文件夹下) ...
- linux的RMP命令(rmp包的安装与反安装)
RMP 是 LINUX 下的一种软件的可执行程序,你只要安装它就可以了.这种软件安装包通常是一个RPM包(Redhat Linux Packet Manager,就是Redhat的包管理器),后缀是. ...
- 基础地图Android SDK
开发者可利用SDK提供的接口,使用百度为您提供的基础地图数据.目前百度地图SDK所提供的地图等级为3-21级,所包含的信息有建筑物.道路.河流.学校.公园等内容. V3.7.0起,地图支持缩放至21级 ...
- poj2774(后缀数组水题)
http://poj.org/problem?id=2774 题意:给你两串字符,要你找出在这两串字符中都出现过的最长子串......... 思路:先用个分隔符将两个字符串连接起来,再用后缀数组求出h ...
- 缓存技术PK:选择Memcached还是Redis(转)
[IT168 技术]要Memcached还是要Redis?在构建一款现代且由数据库驱动的Web应用程序并希望使其拥有更为出色的性能表现时,这个问题总会时不时出现.并给每一位开发人员带来困扰.在考虑对应 ...
- js 拼接字符串 穿参数 带有单引号
var html="<a href=\"#\" onclick=Unlock(\""+flid+"\",1)>弹出& ...
- HTML5关于上传API的一些使用(下)
通过前面两篇的分享,我们已经搞定了单个文件的普通的上传,包括文件预览,图片预览,上传速度等前端界面的显示,这次我们来谈谈关于>XMLHttpRequest2.0在界面之后假如才用分片上传能做到一 ...