当前位置:网站首页>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/PAThttps://github.com/ZouJiu1/PAT
边栏推荐
- "All majors are persuading them to quit." is it actually the most friendly to college students?
- Yuantou firm offer weekly record 20220627
- Learn Tai Chi Maker - mqtt Chapter 2 (3) reserved messages
- How to solve the problem of low applet utilization
- Look! In June, 2022, the programming language ranking list was released! The first place is awesome
- pytorch 23 hook的使用与介绍 及基于hook实现即插即用的DropBlock
- paddlepaddle 20 指数移动平均(ExponentialMovingAverage,EMA)的实现与使用(支持静态图与动态图)
- Oracle/PLSQL: VSize Function
- lodash get js代码实现
- Oracle/PLSQL: Upper Function
猜你喜欢
执念斩长河暑期规划
Svg drag dress Kitty Cat
学习太极创客 — MQTT 第二章(一)QoS 服务质量等级
Learning Tai Chi Maker - mqtt (VII) advanced mqtt theme
学习太极创客 — MQTT 第二章(二)ESP8266 QoS 应用
What if asreml-r does not converge in operation?
1. Project preparation and creation
pytorch_grad_cam——pytorch下的模型特征(Class Activation Mapping, CAM)可视化库
Learn Tai Chi Maker - mqtt (VIII) esp8266 subscribe to mqtt topic
Mmdetection valueerror: need at least one array to concatenate solution
随机推荐
学习太极创客 — MQTT 第二章(三)保留消息
mmdetection ValueError: need at least one array to concatenate解决方案
Press key to control LED status reversal
[micro service sentinel] degradation rules slow call proportion abnormal proportion abnormal constant
docker部署redis集群
h5液体动画js特效代码
清华&华为等 综述 | 语义通信:原则与挑战
Leetcode 785: judgment bipartite graph
Super détaillé, 20 000 caractères détaillés, mangez à travers es!
学习太极创客 — MQTT(九)ESP8266 同时订阅和发布 MQTT 消息
Yuantou firm offer weekly record 20220627
Questions and answers of chlor alkali electrolysis process in 2022
Flink learning 2: application scenarios
pytorch 23 hook的使用与介绍 及基于hook实现即插即用的DropBlock
Microsoft365开发人员申请
Oracle/PLSQL: Substr Function
Flink学习3:数据处理模式(流批处理)
Parameter estimation -- Chapter 7 study report of probability theory and mathematical statistics (point estimation)
Canvas particles: mouse following JS effect
Don't be brainwashed. This is the truth about the wages of 90% of Chinese people