1025 PAT Ranking

基于ProXmoX VE的虚拟化家庭服务器(篇一)—ProXmoX VE 安装及基础配置 ProxmoxVE是一款套开源的虚拟化管理软件,用户可通过网页的方式来管理服务器上使用kvm以及lxc技术运行的虚拟机。同时提供了一些先进功能的支持,如集群、HA等。PVE虽然是开源,却是由一个商业公司在运营、更新以及维护。... 阅读详情

1025 PAT Ranking (25 point(s))

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

本题给出PAT不同城市考生的成绩,要求分别给出考生的总排名和城市排名。需要注意的是,相同分数的人排名需要相同。

注意点:

1. 排名赋值方法,解决同分同名次问题(为了方便,这里count是从1开始计数的)。

2. 对于分城市的排名,当遍历到城市序号对应的时候开始操作。和总排名不一样的是,需要记录上一个排名到的城市,而不能像排总名次那样直接和上一个比较。

解题过程中踩坑:

1.  因为count是从1开始计数,所以sort的两个迭代器分别是r+1,r+1+count-1=r+count。否则测试点2、3不能通过。

2. 分城市的for循环中,if语句不能作为for的第二个参数。因为for循环进入循环体时不会首先判断是否满足限制。否则测试点0、2、3不通过。

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct record{
	string id;
	int grade,final_rank,loc_id,loc_rank;
	bool operator < (const record &other) const{
		if(grade!=other.grade) return grade>other.grade;
		else return id<other.id;
	}
}; 
record r[30010];
int main(void)
{
	int N,K;
	int count=1;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>K;
		for(int j=0;j<K;j++){
			cin>>r[count].id>>r[count].grade;
			r[count].loc_id=i;
			count++;
		}
	}
	sort(r+1,r+count);
	for(int i=1;i<=count;i++){
		if(i==1||r[i].grade!=r[i-1].grade) r[i].final_rank=i;
		else r[i].final_rank=r[i-1].final_rank;
	}
	for(int i=1;i<=N;i++){
		int lr = 1;int last_locid=1;
		for(int j=1;j<=count;j++){
			if(r[j].loc_id==i){
				if(lr==1||r[j].grade!=r[last_locid].grade) r[j].loc_rank=lr;
				else r[j].loc_rank=r[last_locid].loc_rank;
				lr++;
				last_locid=j;
			}
		}
	}
	cout<<count-1<<endl;
	for(int i=1;i<=count-1;i++){
		cout<<r[i].id<<" "<<r[i].final_rank<<" "<<r[i].loc_id<<" "<<r[i].loc_rank<<endl;
	}
	return 0;
}

 

《S32系列芯片——Boot & HSE详解》持续更新中... 专栏总目录,将详细介绍S32系列芯片的Boot功能,最终给出HSE基于IVT的Secure Boot方案!!! 阅读详情

相关推荐

[原创]Linux 802.11n CSI tool Monitor模式

Linux 802.11n CSI tool Monitor模式 使用AP模式的缺陷在于ping 命令速度比较慢,且不能精确控制发送的参数,比如接收的包数量是不可控的。Monitor模式可以调制发送速率、发包数量、发送天线个数、HT模式、short/long guard interval等等,因此调通Monitor模式是必须的。期间参考了博主沃一德的CSI Tool安装使用讲解,对他的工作表示感...

u014645508的博客 1万+

【leetcode】1030 距离顺序排列矩阵单元格 Matrix Cells in Distance

【LeetCode】1030 距离顺序排列矩阵单元格 Matrix Cells in Distance

pyy_lucy的博客 214

南大计算机2024保研笔试:编译原理等5门专业课考点分布与408复习避坑指南

本文详细解析了南京大学计算机2024保研笔试的考点分布与复习策略,重点突出编译原理(占比28%-32%)和离散数学的特色考核。提供跨课程复习方法、真题题型分析及高效备考建议,帮助考生突破传统408框架,应对南大独特的命题风格。

weixin_29304985的博客 347

1025 PAT Ranking(排序)

1025 PAT Ranking

老顽固也可爱 277

【Unity动画系统】详解Root Motion动画在Unity中的应用(一)

什么时候勾选Bake into pose,当不希望动画带动游戏对象旋转时。在旋转的动画中一般是不用勾选的,因为就需要用它来带动我们的角色对象旋转。但在比如前进、后退、待机等动画来说,我们就可以勾选这里,以避免因动画文件本身的瑕疵而给我们带来的旋转。loop match:代表了这个动画在角度上的吻合度。如果这个动画在播放中转角过大,那么就会显示红色,告诉我们如果勾选bake into pose,则会带来不好的效果。

weixin_60154963的博客 6805

Spring WebFlux响应式编程实战(三):优雅处理异常与高效调试技巧

本文深入探讨了Spring WebFlux响应式编程中的异常处理与调试技巧。文章通过电商订单流处理场景,详细解析了Reactor核心操作符onErrorReturn、onErrorResume和onErrorMap的实战应用,并介绍了如何构建@ControllerAdvice和WebExceptionHandler全局异常处理防线。同时,提供了使用.log()操作符、Hooks.onOperatorDebug()及BlockHound进行高效调试的方法,旨在帮助开发者构建健壮、可维护的响应式应用。

weixin_29252171的博客 67

1025. PAT Ranking (25)-PAT甲级真题

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 pla

柳婼 の blog 2421

IAR9.4报错之编码方式

IAR9.40编码方式错误导致的报错

qq_36081075的博客 2626

[PAT甲级]1025 PAT Ranking 详细题解+AC代码

以下所述均为个人理解,如有错误,还望指正。

zzylalalala的博客 1161

RTK_ROS_导航(4):接入move_base

现在我们要将之前的数据接入到Move_base中,使得机器人能够根据Map上的终点进行导航,并且实现避障效果如下图。

旋风小短腿 1947

PowerDesigner 数据库建模使用详解

PowerDesigner 数据库建模使用详解

congge 7082

【PAT甲级题解记录】1025 PAT Ranking (25 分)

问题描述 PAT 考试有不同考场,给出不同考场的学生成绩,要求汇总后根据成绩高低输出考生id、考场号、考场排名、总排名。 解题思路 我们写一个结构体用来存储学生信息:id、考场号、成绩、考场排名、总排名,结构体排序以成绩降序为第一顺序,考场id为第二顺序。 输入每个考场的学生信息,包括id、考场号和成绩。然后对这个考场的考生成绩排序,拍完序后可以得到这个考场每个学生考场排名。 最后把所有学生一起排序,同理得到每个学生的总排名。

retr0的博客 232

GEE:基于 Landsat 数据集生成(1986-2024)月度合成地表温度(LST)时间序列数据

优快云@_养乐多_本文将介绍使用 Landsat 时间序列计算(1986-2024)月度合成地表温度(LST)时间序列数据集的代码。

养乐多的博客 1714

PAT甲级 1025 Ranking

PAT甲级 1025 Ranking 题目传送门 题目输入 line1 : num_loc(考场个数) line2 : num_tInloc (第i个考场学生数) line3 ~( num_tInloc + 3) : id(考号),score(考生成绩) (重复以上line2~line( num_tInloc + 3) 格式) 要求输出 line1 : num_testees (总考生数) line2~(num_testees + 1): id(考号),rank_all (总排名),id_loc(考场号

weixin_45549370的博客 167

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

【PAT1025】PAT Ranking

1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programming Ability Test (PAT) is organized by

天堂人间 2565

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

PAT甲级(Advanced Level) Practice 1025 PAT Ranking

先对每组学生数据进行处理,然后全部存入数组中进行总的处理。

2301_78006009的博客 331

PAT-1025 PAT Ranking

1025 PAT Ranking part 2, 2.1 自己解法(未全对) 4 WA,但是牛客网中可以全对 #include <iostream> using namespace std; #include <vector> #include <map> #include <algorithm> struct test { long long number; int grade; int loc; int rank[

seven_colors的博客 324

1025 PAT Ranking

1025 PAT Ranking #include <stdio.h> #include <string.h> #include <cstring> #include <algorithm> using namespace std; struct Student{ char id[15]; // 准考证号 int score; //...

m0_37938791的博客 209

PAT甲级 1025 PAT Ranking

PAT甲级 1025 PAT Ranking 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 plac...

旺崽的博客 2902

PAT 1025 PAT Ranking

PAT 1025 PAT Ranking #include <bits/stdc++.h> using namespace std; const int N = 3e4 + 10; struct student{ string id; // 账号 int score; // 分数 int loc_id; // 考点号 int loc_r; // 考点排名 i...

小韦同学的博客 271

PAT 甲级 1025 PAT Ranking

PAT 甲级 1025 PAT Ranking

Dacc123的博客 1122

PAT 1025 PAT ranking

题目要求: 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 rank...

weixin_42379312的博客 200

PAT A1025 PAT Ranking

PAT A1025 PAT Ranking 自己做的和书上答案大体一致,但在local_ranking问题上卡壳了,菜啊<_> 代码如下: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; //定义结构体 struct Student{ c...

Z_Zll_cslearning的博客 222
上一篇: 1028 List Sorting
下一篇: 1024 Palindromic Number
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值