problem

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

tip

answer

#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
struct student {
long long int no;
int score, finrank, loca, locarank;
};
bool cmp1(student a, student b) {
return a.score != b.score ? a.score > b.score : a.no < b.no;
}
int main() {
int n, m;
scanf("%d", &n);
vector<student> fin;
for(int i = 1; i <= n; i++) {
scanf("%d", &m);
vector<student> v(m);
for(int j = 0; j < m; j++) {
scanf("%lld %d", &v[j].no, &v[j].score);
v[j].loca = i;
}
sort(v.begin(), v.end(), cmp1);
v[0].locarank = 1;
fin.push_back(v[0]);
for(int j = 1; j < m; j++) {
v[j].locarank = (v[j].score == v[j - 1].score) ? (v[j - 1].locarank) : (j + 1);
fin.push_back(v[j]);
}
}
sort(fin.begin(), fin.end(), cmp1);
fin[0].finrank = 1;
for(int j = 1; j < fin.size(); j++)
fin[j].finrank = (fin[j].score == fin[j - 1].score) ? (fin[j - 1].finrank) : (j + 1);
printf("%d\n", fin.size());
for(int i = 0; i < fin.size(); i++)
printf("%013lld %d %d %d\n", fin[i].no, fin[i].finrank, fin[i].loca, fin[i].locarank);
return 0;
}

experience

  • 就是道简单的模拟题,能不能快一点做完?

1025 PAT Ranking (25)(25 point(s))的更多相关文章

  1. A1025 PAT Ranking (25)(25 分)

    A1025 PAT Ranking (25)(25 分) Programming Ability Test (PAT) is organized by the College of Computer ...

  2. 1025 PAT Ranking (25分)

    1025 PAT Ranking (25分) 1. 题目 2. 思路 设置结构体, 先对每一个local排序,再整合后排序 3. 注意点 整体排序时注意如果分数相同的情况下还要按照编号排序 4. 代码 ...

  3. PAT甲级:1025 PAT Ranking (25分)

    PAT甲级:1025 PAT Ranking (25分) 题干 Programming Ability Test (PAT) is organized by the College of Comput ...

  4. PAT 1085 PAT单位排行(25)(映射、集合训练)

    1085 PAT单位排行(25 分) 每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜.本题就请你实现这个功能. 输入格式: 输入第一行给出一个正整数 N(≤10​5​​),即考生人数.随 ...

  5. PTA PAT排名汇总(25 分)

    PAT排名汇总(25 分) 计算机程序设计能力考试(Programming Ability Test,简称PAT)旨在通过统一组织的在线考试及自动评测方法客观地评判考生的算法设计与程序设计实现能力,科 ...

  6. A1075 PAT Judge (25)(25 分)

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

  7. PAT 甲级 1006 Sign In and Sign Out (25)(25 分)

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  8. 【PAT】1020 Tree Traversals (25)(25 分)

    1020 Tree Traversals (25)(25 分) Suppose that all the keys in a binary tree are distinct positive int ...

  9. 【PAT】1052 Linked List Sorting (25)(25 分)

    1052 Linked List Sorting (25)(25 分) A linked list consists of a series of structures, which are not ...

  10. 【PAT】1060 Are They Equal (25)(25 分)

    1060 Are They Equal (25)(25 分) If a machine can save only 3 significant digits, the float numbers 12 ...

随机推荐

  1. 使用spring的监听器来完成系统超级管理员的注册

    1.注入 2“util类 package com.liveyc.mgrsite.util; import org.springframework.beans.factory.annotation.Au ...

  2. flask跨域请求三行代码搞定

    flask跨域请求三行代码就可以搞定.但是请注意几点: 第一:只能返回json格式数据,比如list.ndarray等都不可以 第二:返回的对象必须是是字符串.元组.响应实例或WSGI可调用. pyt ...

  3. spfa+差分约束系统(C - House Man HDU - 3440 )+对差分约束系统的初步理解

    题目链接:https://cn.vjudge.net/contest/276233#problem/C 题目大意:有n层楼,给你每个楼的高度,和这个人单次的最大跳跃距离m,两个楼之间的距离最小是1,但 ...

  4. Splay算法摘要

    先介绍变量定义 int n; struct Node { //Splay节点定义 ],val,num,siz; //fa:它爸爸:son它儿子,左0右1:val:这个节点的值 //num:这个值的数量 ...

  5. 简单的搭mysql开发环境

    所需软件  环境win8 64bit mysql5.7.16winx64.zip mysql-workbench-community-6.3.5-win32.zip 安装完了之后到mysql/bin下 ...

  6. IP地址、域名、域名解析系统相关

    IP地址(Internet Protocol Address) 它来自TCP/IP协议,存在于其中的IP层,用于实现不同计算机之间的通信,类似于门牌号. 设计之处,IP地址是准备给地球上每一台计算机一 ...

  7. SQL-如果指定值存在返回1,如果不存在返回0的SQL语句

    想实现简单的判断一个表中是否有一条记录,可以用这个方式.如以下,table_name是表名,column1是列名. 这条语句会在此条记录存在的时候返回1,不存在时返回0. FROM table_nam ...

  8. 本地为Windows,使用Xshell登录Linux云主机

    以某东的云主机为实例 1. 下载并安装远程登录软件 下载Xshell软件 下载后双击xshell5_5.0.1332.exe进行安装 2. 安装完成,打开Xshell,并点击新建,根据要求输入相应参数 ...

  9. HDU 2609 How many(最小表示+set)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609 题目大意: 题目大意有n个有01组成的字符串,每个字符串都代表一个项链,那么该字符串就是一个环状 ...

  10. 20165203《Java程序设计》第五周学习总结

    教材学习内容总结 第七章 内部类 注意内部类和外嵌类的关系: 外嵌类的成员变量和方法在内部类有效 内部类的类体不可以声明static变量和方法.外嵌类的类体可以用内部类声明对象. 内部类仅供它的外嵌类 ...