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 ...
随机推荐
- Qt 检验器 三种典型类的用法
Qt提供了三个内置验证器类: QDoubleValidator, QIntValidator, QRegExpValidator. QDoubleValidator类: 提供了对浮点数的范围检查. Q ...
- 关于DebuggerHidden特性在Unity中的使用
经过测试,DebuggerHidden只对输出的日志有影响.对编辑器的控制台输入没有影响 你可以通过这个特性避免日志log有一堆的堆栈信息 并且测试过发现Debug.LogError也不支持该特性,和 ...
- alloc retain release函数
- Selenium 之18 种定位方式
1 id 定位 driver.find_element_by_id() HTML 规定id 属性在HTML 文档中必须是唯一的.这类似于公民的身份证号,具有很强的唯一性 from selenium i ...
- web中文字体Font-family应该写什么?
最佳实践是: font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑",STXihei, ...
- 图解Sysprep封装系统
图解Sysprep封装系统 一.使用安装管理器工具创建 Sysprep.inf 应答文件 要安装“安装管理器”工具并创建应答文件,请按照下列步骤操作: 1)打开“我的电脑”,然后打开 Wind ...
- 基于js全屏动画焦点图幻灯片
今天给大家分享一款基于js全屏动画焦点图幻灯片.这款焦点图内的内容以动画形式出现和消失.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class="sl ...
- Unix系统编程()信号:概念和概述
这篇将一口气学完信号的基本概念,但是有很多的细节,所以篇幅较长,请做好心理准备. (他大爷的,一口气没有学完,太懒了) 有以下主题: 各种不同信号及其用途 内核可能为进程产生信号的环境,以及某一进程向 ...
- http://jadethao.iteye.com/blog/1926525
http://jadethao.iteye.com/blog/1926525 ————————————————————————————————————————————————————————————— ...
- 10个 jQuery 小技巧
10个 jQuery 小技巧 -----整理by: xiaoshuai 1. 返回顶部按钮 可以利用 animate 和 scrollTop 来实现返回顶部的动画,而不需要使用其他插件. // Bac ...