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. Q_PROPERTY介绍

    QT提供了一个成熟的属性系统,但是作为一个跨平台的且与编译器无关的库,qt不依赖于非标准的编译器功能例如 __property or [property]: QT的强大之处在于它可以支持任何标准的c+ ...

  2. [svc]sudo su权限案例

    一 控制sudo 允许执行所有命令,排除某几个命令(带参数) lanny ALL=(ALL) NOPASSWD:ALL, !/bin/su - root, !/usr/sbin/visudo 如果需要 ...

  3. /^(0|[1-9]\d*)([.]5)?$/ 在PHP正则中是什么意思 ?

    ^以什么开头 ()分组 |或的意思 \d 匹配任何数字字符串 [-] |[-]\d* 或1-9之间的数+任意数字零次或多次 开头 ()分组 []原子表 [.]5匹配. ? 零次或1次 总结: 必须以0 ...

  4. maven中配置jdk版本

    1 maven 中配置 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins< ...

  5. python操作excel之 模块 xlrd (详解)

    二.使用介绍 1.导入模块 import xlrd 2.打开Excel文件读取数据 data = xlrd.open_workbook('excelFile.xls') 3.使用技巧 获取一个工作表 ...

  6. Linux安装MediaWiki

    1.    编译安装libxml2 # wget http://xmlsoft.org/sources/libxml2-2.6.32.tar.gz # tar zxvf libxml2-2.6.32. ...

  7. Android基础总结(八)Service

    服务两种启动方式(掌握) startService 开始服务,会使进程变成为服务进程 启动服务的activity和服务不再有一毛钱关系 bindService 绑定服务不会使进程变成服务进程 绑定服务 ...

  8. C++ new delete操作符

    //new delete操作符 #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; /* 1.n ...

  9. 使用OpenFace进行人脸识别(2)

    http://blog.csdn.net/u011531010/article/details/52270023 http://www.vccoo.com/v/2ed520 第一步 在 openfac ...

  10. git 停止在12% writing objects 怎么回事?

    git 停止在12% writing objects 怎么回事? 输入以下代码试一下: git config --global http.postBuffer 524288000