当前位置:网站首页>PAT甲级 1025 PAT Ranking
PAT甲级 1025 PAT Ranking
2022-06-27 02:44:00 【九是否非随机的称呼】
注意ranking是累加
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
struct testee{
string ID;
int score;
int loc;
int wholerank;
int locrank;
};
bool compareloc(const testee &a, const testee &b){
if(a.score > b.score) return true;
else if(a.score < b.score) return false;
else if(a.score == b.score){
if(a.ID <= b.ID) return true;
else return false;
}
}
int main(void){
string s, s0, sk;
int m, n, k, i, j, f, h;
cin>>n;
vector<testee> v, vx;
testee tst;
vector<int> vtr;
for(i = 0; i < n; i++){
cin>>m;
vtr.push_back(m);
for(j = 0; j < m; j++){
cin>>tst.ID>>tst.score;
tst.loc = i + 1;
vx.push_back(tst);
}
}
h = 0;
for(i = 0; i < n; i++){
vector<testee> v0;
k = 1;
for(j = 0; j < vtr[i]; j++){
tst = vx[h++];
v0.push_back(tst);
}
sort(v0.begin(), v0.end(), compareloc);
if(v0.size()>0) v0[0].locrank = k;
for(j = 1; j < vtr[i]; j++){
k++;
if(v0[j - 1].score==v0[j].score) v0[j].locrank = v0[j - 1].locrank;
else v0[j].locrank = k;
}
for(j = 0; j < vtr[i]; j++) v.push_back(v0[j]);
}
k = 1;
sort(v.begin(), v.end(), compareloc);
if(v.size()>0) v[0].wholerank = k;
for(j = 1; j < v.size(); j++){
k++;
if(v[j - 1].score==v[j].score) v[j].wholerank = v[j - 1].wholerank;
else v[j].wholerank = k;
}
cout<<v.size()<<endl;
for(j = 0; j < v.size(); j++) cout<<v[j].ID<<" "<<v[j].wholerank<<" "<<v[j].loc<<" "<<v[j].locrank<<endl;
return 0;
} https://github.com/ZouJiu1/PAT
https://github.com/ZouJiu1/PAT
边栏推荐
- Learn Tai Chi Maker - mqtt (VIII) esp8266 subscribe to mqtt topic
- 解决cherry pick提交报错问题
- C # check whether the date is in the correct format
- DAMA、DCMM等数据管理框架各个能力域的划分是否合理?有内在逻辑吗?
- Fork (), exec (), waitpid (), $? > > in Perl 8 combination
- Oracle/PLSQL: Ltrim Function
- Flink學習2:應用場景
- How does the C # TCP server limit the number of connections to the same IP?
- Svg drag dress Kitty Cat
- Learning Tai Chi Maker - mqtt (VII) advanced mqtt theme
猜你喜欢

学习太极创客 — MQTT(八)ESP8266订阅MQTT主题

How does source insight (SI) display the full path? (do not display omitted paths) (turn off trim long path names with ellipses)

Yiwen teaches you Kali information collection

企业数字化转型:信息化与数字化

C language -- Design of employee information management system

Flink learning 3: data processing mode (stream batch)

Learn Tai Chi maker mqtt (IX) esp8266 subscribe to and publish mqtt messages at the same time

【微服务|Sentinel】降级规则|慢调用比例|异常比例|异常数

Window 加密壳实现

lottie. JS creative switch button animal head
随机推荐
Getting started with bluecms code auditing
2022中式面点师(高级)复训题库及在线模拟考试
How to solve the problem of low applet utilization
The use and introduction of pytorch 23 hook and the implementation of plug and play dropblock based on hook
Oracle/PLSQL: To_ Clob Function
【一起上水硕系列】Day 6
STM32入门介绍
Calculation of average wind direction and speed (unit vector method)
C language -- Design of employee information management system
P5.js death planet
人群模拟
Would rather go to 996 than stay at home! 24 years old, unemployed for 7 months, worse than work, no work
Mmdetection valueerror: need at least one array to concatenate solution
TopoLVM: 基于LVM的Kubernetes本地持久化方案,容量感知,动态创建PV,轻松使用本地磁盘
jwt的认证流程和使用案例
Press key to control LED status reversal
Flink learning 2: application scenarios
学习太极创客 — MQTT(六)ESP8266 发布 MQTT 消息
Record the method of reading excel provided by unity and the solution to some pits encountered
平均风向风速计算(单位矢量法)