1025. PAT Ranking (25)

时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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
不知道为什么用longlong 表示registration 最后一组过不了,用string就可以了
#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的更多相关文章

  1. PAT甲级——1025 PAT Ranking

    1025 PAT Ranking Programming Ability Test (PAT) is organized by the College of Computer Science and ...

  2. PAT 甲级 1025.PAT Ranking C++/Java

      Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Z ...

  3. PAT 甲级1025 PAT Ranking (25 分)(结构体排序,第一次超时了,一次sort即可小技巧优化)

    题意: 给定一次PAT测试的成绩,要求输出考生的编号,总排名,考场编号以及考场排名. 分析: 题意很简单嘛,一开始上来就,一组组输入,一组组排序并记录组内排名,然后再来个总排序并算总排名,结果发现最后 ...

  4. 【PAT】1025. PAT Ranking (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1025 题目描述: Programming Ability Test (PAT) is orga ...

  5. PAT 甲级 1141 PAT Ranking of Institutions

    https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...

  6. PAT甲级——A1025 PAT Ranking

    Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhe ...

  7. PAT甲级1075 PAT Judge

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805393241260032 题意: 有m次OJ提交记录,总共有k道 ...

  8. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  9. PAT甲级——A1075 PAT Judge

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

随机推荐

  1. Xilinx-7Series-FPGA高速收发器使用学习—TX发送端介绍

    每一个收发器拥有一个独立的发送端,发送端有PMA(Physical Media Attachment,物理媒介适配层)和PCS(PhysicalCoding Sublayer,物理编码子层)组成,其中 ...

  2. 常见的安装包制作程序installer

    1. Windows安装程序制作工具 NSISNSIS (Nullsoft Scriptable Install System) 是一个专业开源的制作 windows 安装程序的工具.http://n ...

  3. Linux系统CPU频率调整工具使用

    现在的CPU耗电很大,按需调节CPU频率对普通桌面及移动设备节能有重要的意义,目前多数Linux发行版都已经默认启用了这个功能,但在一些像数据库,集群系统等特别需要CPU高性能的服务器环境中,Linu ...

  4. cocos2d-x中的宏定义CC_PROPERTY

    cocos2d-x定义了很多宏定义,帮我们提高开发效率,下面看下CC_PROPERTY, CC_PROPERTY定义 CC_PROPERTY的声明在CCPlatformMacros.h中,结构如下 # ...

  5. CXSprite.h文件

    #ifndef __XSprite_H__ #define __XSprite_H__ #include "CocoHead.h" #define BTN_FRAME_AMOUNT ...

  6. Apache Rewrite 拟静态

    mod_rewrite是Apache的一个非常强大的功能,它可以实现伪静态页面.一些防盗链就是通过该方法做到的. 00x1 启动rewrite引擎 00x2 如何启用apache rewrite? 0 ...

  7. PHP——0128练习相关2——js点击button按钮跳转到另一个新页面

    js点击button按钮跳转到另一个新页面 投稿:whsnow 字体:[增加 减小] 类型:转载 时间:2014-10-10我要评论 点击按钮怎么跳转到另外一个页面呢?点击图片要跳转到新的页面时,怎么 ...

  8. Enlish相关术语

    APM 自动编程机(Automatic Programming Machine) 高级电源管理(Advanced Power Management) OSD 屏幕显示(On Screen Displa ...

  9. Leetcode_num4_Reverse Integer

    题目: Reverse digits of an integer. Have you thought about this? Here are some good questions to ask b ...

  10. python3----输出所有大小写字母及数字

    1. 用一行输出所有大(小)写字母,以及数字 print([chr(i) for i in range(65, 91)]) # 所有大写字母 print([chr(i) for i in range( ...