PAT_A1141#PAT Ranking of Institutions
Source:
Description:
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 (≤), 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 andT
the top level;Score
is an integer in [0, 100]; andSchool
is the institution code which is a string of no more than 6 English letters (case insensitive). Note: it is guaranteed thatID
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 ofScoreB/1.5 + ScoreA + ScoreT*1.5
, whereScoreX
is the total score of the testees belong to this institution on levelX
; andNs
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 ofNs
. 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
Keys:
- map(C++ STL)
- string(C++ STL)
- 快乐模拟
Attention:
- 字符串转换为小写:transform(s.begin(),s.end(),s.begin(),::tolower);
- 字符串转换为大写:transform(s.begin(),s.end(),s.begin(),::toupper);
- 分数用double存储,比较总分时再取整数部分,若计算各个Int再相加,会有误差
- cmp,rank,printf,三处的比分都要用整数,各对应一个测试点
Code:
/*
Data: 2019-08-06 20:19:45
Problem: PAT_A1141#PAT Ranking of Institutions
AC: 33:40 题目大意:
按分数排名
输入:
第一行给出,考试人数N<=1e5
接下来N行给出,ID(1位字母+5位数字),分数[0,100],学校(<=6,大小写敏感)
输出:
第一行输出,学校总数M
接下来M行,排名(>=1), 学校(小写),总分(B/1.5+A+T*1.5),考生数
排序规则,总分递减,人数递增,学校字典序
*/
#include<cstdio>
#include<string>
#include<map>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1e5+;
int pos=;
map<string,int> mp;
struct node
{
string sch;
double score;
int num;
}ans[M]; int Hash(string s)
{
if(mp[s]==)
{
ans[pos]=node{s,,};
mp[s]=pos++;
}
return mp[s];
} bool cmp(const node &a, const node &b)
{
if((int)a.score != (int)b.score)
return a.score > b.score;
else if(a.num != b.num)
return a.num < b.num;
else
return a.sch < b.sch;
} int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE int n;
scanf("%d", &n);
for(int i=; i<n; i++)
{
string id,sc;
double grade;
cin >> id >> grade >> sc;
transform(sc.begin(),sc.end(),sc.begin(),::tolower);
int pt = Hash(sc);
if(id[]=='T') grade *= 1.5;
if(id[]=='B') grade /= 1.5;
ans[pt].score += grade;
ans[pt].num++;
}
sort(ans+,ans+pos,cmp);
int r=;
printf("%d\n", pos-);
for(int i=; i<pos; i++)
{
if(i!= && (int)ans[i-].score != (int)ans[i].score)
r=i;
printf("%d %s %d %d\n", r,ans[i].sch.c_str(),(int)ans[i].score,ans[i].num);
} return ;
}
PAT_A1141#PAT Ranking of Institutions的更多相关文章
- 1141 PAT Ranking of Institutions[难]
1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of ...
- A1141. PAT Ranking of Institutions
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- PAT 甲级 1141 PAT Ranking of Institutions
https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PA ...
- [PAT] 1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- 1141 PAT Ranking of Institutions (25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- PAT 1141 PAT Ranking of Institutions
After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...
- 1141 PAT Ranking of Institutions
题意:给出考生id(分为乙级.甲级和顶级),取得的分数和所属学校.计算各个学校的所有考生的带权总成绩,以及各个学校的考生人数.最后对学校进行排名. 思路:本题的研究对象是学校,而不是考生!因此,建立学 ...
- PAT Ranking (排名)
PAT Ranking (排名) Programming Ability Test (PAT) is organized by the College of Computer Science and ...
随机推荐
- 洛谷——P2722 总分 Score Inflation
https://www.luogu.org/problem/show?pid=2722 题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这 ...
- LINUX 内核内存管理
https://linux-mm.org/ http://www.cnblogs.com/liloke/archive/2011/11/20/2255737.html
- PHP项目的设计过程
过程说明: 1)产品部依据需求设计出原型图和需求文档. 2)产品部和需求方与技术一起过一遍需求. 这样能够让需求方确认需求:和所參与的技术(设计部,制作部,php,測试部等)对要设计的产品有一个大致的 ...
- Lucene5学习之使用MMSeg4j分词器
分类:程序语言|标签:C|日期: 2015-05-01 02:00:24 MMSeg4j是一款中文分词器,详细介绍如下: 1.mmseg4j 用 Chih-Hao Tsai 的 MMSeg 算法( ...
- Linux线程池在server上简单应用
一.问题描写叙述 如今以C/S架构为例.client向server端发送要查找的数字,server端启动线程中的线程进行对应的查询.将查询结果显示出来. 二.实现方案 1. 整个project以cli ...
- 【Allwinner ClassA20类库分析】4.GPIO类的使用
从本节起,開始使用ClassA20类库完毕操作外设的功能,请先在https://github.com/tjCFeng/ClassA20下载ClassA20类库. 封装的目的就是简化操作,试想一 ...
- libcurl实现解析(3) - libcurl对select的使用
1.前言 在本系列的前一篇文章中.介绍了libcurl对poll()的使用. 參考"libcurl原理解析(2) - libcurl对poll的使用". 本篇文章主要分析curl_ ...
- 转:Java阳历转农历
package cloud.app.prod.home.utils; import java.text.ParseException; import java.text.SimpleDateForma ...
- Android - Fragment BackStack 清空
Fragment BackStack 清空 int backStackCount = getFragmentManager().getBackStackEntryCount(); for(int i ...
- 洛谷 P3515 [ POI 2011 ] Lightning Conductor —— 决策单调性DP
题目:https://www.luogu.org/problemnew/show/P3515 决策单调性... 参考TJ:https://www.cnblogs.com/CQzhangyu/p/725 ...