1141 PAT Ranking of Institutions-PAT甲级(多重排序+map)

本文介绍了一种用于PAT竞赛的机构排名算法,该算法根据学生的表现为各机构生成排名列表,考虑了不同测试级别的加权分数和总人数,通过结构体存储学校信息并实现了排序逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤10​5​​), which is the number of testees. Then N lines follow, each gives the information of a testee in the following format:

ID Score School

where ID is a string of 6 characters with the first one representing the test level: B stands for the basic level, A the advanced level and T the top level; Score is an integer in [0, 100]; and School is the institution code which is a string of no more than 6 English letters (case insensitive). Note: it is guaranteed that ID is unique for each testee.

Output Specification:

For each case, first print in a line the total number of institutions. Then output the ranklist of institutions in nondecreasing order of their ranks in the following format:

Rank School TWS Ns

where Rank is the rank (start from 1) of the institution; School is the institution code (all in lower case); ; TWS is the total weighted score which is defined to be the integer part of ScoreB/1.5 + ScoreA + ScoreT*1.5, where ScoreX is the total score of the testees belong to this institution on level X; and Ns is the total number of testees who belong to this institution.

The institutions are ranked according to their TWS. If there is a tie, the institutions are supposed to have the same rank, and they shall be printed in ascending order of Ns. If there is still a tie, they shall be printed in alphabetical order of their codes.

Sample Input:

10
A57908 85 Au
B57908 54 LanX
A37487 60 au
T28374 67 CMU
T32486 24 hypu
A66734 92 cmu
B76378 71 AU
A47780 45 lanx
A72809 100 pku
A03274 45 hypu

Sample Output:

5
1 cmu 192 2
1 au 192 3
3 pku 100 1
4 hypu 81 2
4 lanx 81 2

定义一个结构体来存储学校的排名,名字,总得分以及总人数,在结构体中定义排序的顺序

注意:对于总成绩的计算方法,在计算的过程中应采取double的类型来计算,在最后比较的时候在取整,以免有误差出现

满分代码如下:

#include<bits/stdc++.h>
using namespace std;
const int N=100005;
struct Node{
	int id;
	string school;
	int score=0;
	int num=0;
	bool operator < (const Node &a)const{
		if(score!=a.score)
			return score>a.score;
		else if(num!=a.num)
			return num<a.num;
		return school<a.school;
	}
}node[N];
map<int,double>mp;
map<string,int>mt;
int n;
int main(){
	int cnt=0;
	scanf("%d",&n);
	string id,school;
	double score;
	for(int i=1;i<=n;i++){
		cin>>id>>score>>school;
		for(int j=0;j<school.size();j++){
			school[j]=tolower(school[j]);
		}
	    if(mt[school]==0){
	    	cnt++;
	    	mt[school]=cnt;
		}
		node[mt[school]].school=school;
		if(id[0]=='B')
			mp[mt[school]]+=(score/1.5);
		else if(id[0]=='A')
			mp[mt[school]]+=(score);
		else if(id[0]=='T')
			mp[mt[school]]+=(score*1.5);
		node[mt[school]].num+=1;
	}
	for(int i=1;i<=cnt;i++){
		node[i].score=(int)(mp[i]);
	}
	sort(node+1,node+cnt+1);
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++){
		if(i==1){
			node[i].id=i;
		}	
		else if(node[i].score==node[i-1].score){
			node[i].id=node[i-1].id;
		}else{
			node[i].id=i;
		}
		printf("%d %s %d %d\n",node[i].id,node[i].school.c_str(),node[i].score,node[i].num);
	}
	return 0;
}

 

标题基于SpringBoot+Vue的社区便民服务平台研究AI更换标题第1章引言介绍社区便民服务平台的研究背景、意义,以及基于SpringBoot+Vue技术的研究现状和创新点。1.1研究背景与意义分析社区便民服务的重要性,以及SpringBoot+Vue技术在平台建设中的优势。1.2国内外研究现状概述国内外在社区便民服务平台方面的发展现状。1.3研究方法与创新点阐述本文采用的研究方法和在SpringBoot+Vue技术应用上的创新之处。第2章相关理论介绍SpringBoot和Vue的相关理论基础,以及它们在社区便民服务平台中的应用。2.1SpringBoot技术概述解释SpringBoot的基本概念、特点及其在便民服务平台中的应用价值。2.2Vue技术概述阐述Vue的核心思想、技术特性及其在前端界面开发中的优势。2.3SpringBoot与Vue的整合应用探讨SpringBoot与Vue如何有效整合,以提升社区便民服务平台的性能。第3章平台需求分析与设计分析社区便民服务平台的需求,并基于SpringBoot+Vue技术进行平台设计。3.1需求分析明确平台需满足的功能需求和性能需求。3.2架构设计设计平台的整体架构,包括前后端分离、模块化设计等思想。3.3数据库设计根据平台需求设计合理的数据库结构,包括数据表、字段等。第4章平台实现与关键技术详细阐述基于SpringBoot+Vue的社区便民服务平台的实现过程及关键技术。4.1后端服务实现使用SpringBoot实现后端服务,包括用户管理、服务管理等核心功能。4.2前端界面实现采用Vue技术实现前端界面,提供友好的用户交互体验。4.3前后端交互技术探讨前后端数据交互的方式,如RESTful API、WebSocket等。第5章平台测试与优化对实现的社区便民服务平台进行全面测试,并针对问题进行优化。5.1测试环境与工具介绍测试
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值