当前位置:网站首页>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
边栏推荐
- Oracle/PLSQL: NumToYMInterval Function
- ConstraintLayout(约束布局)开发指南
- 学习太极创客 — MQTT(六)ESP8266 发布 MQTT 消息
- Canvas particles: mouse following JS effect
- 谷歌开始卷自己,AI架构Pathways加持,推出200亿生成模型
- lottie. JS creative switch button animal head
- Docker deploy redis cluster
- Super détaillé, 20 000 caractères détaillés, mangez à travers es!
- Test the respective roles of nohup and &
- Oracle/PLSQL: VSize Function
猜你喜欢

Flink learning 2: application scenarios

Flink learning 1: Introduction

Super detailed, 20000 word detailed explanation, thoroughly understand es!

Learn Tai Chi Maker - mqtt Chapter 2 (3) reserved messages

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

ConstraintLayout(约束布局)开发指南

流沙画模拟器源码

TechSmith Camtasia最新2022版详细功能讲解下载

Sample development of WiFi IOT Hongmeng development kit

Flink学习4:flink技术栈
随机推荐
455. distribute biscuits [distribution questions]
"All majors are persuading them to quit." is it actually the most friendly to college students?
Why pass SPIF_ Sendchange flag systemparametersinfo will hang?
Record the method of reading excel provided by unity and the solution to some pits encountered
Google began to roll itself, AI architecture pathways was blessed, and 20billion generation models were launched
C language -- Design of employee information management system
Yalm 100b: 100billion parameter open source large model from yandex, Russia, allowing commercial use
lottie.js创意开关按钮动物头像
Introduction to stm32
Laravel 的 ORM 缓存包
three. JS domino JS special effect
Super détaillé, 20 000 caractères détaillés, mangez à travers es!
Oracle/PLSQL: Trim Function
Test the respective roles of nohup and &
Quicksand painting simulator source code
Sample development of WiFi IOT Hongmeng development kit
Dameng database installation
Look! In June, 2022, the programming language ranking list was released! The first place is awesome
Flink learning 4:flink technology stack
C# Tcp服务器如何限制同一个IP的连接数量?