当前位置:网站首页>1025 PAT Ranking
1025 PAT Ranking
2022-06-27 19:50:00 【Brosto_ Cloud】
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge all the ranklists and generate the final rank.
Input Specification:
Each input file contains one test case. For each case, the first line contains a positive number N (≤100), the number of test locations. Then N ranklists follow, each starts with a line containing a positive integer K (≤300), the number of testees, and then K lines containing the registration number (a 13-digit number) and the total score of each testee. All the numbers in a line are separated by a space.
Output Specification:
For each test case, first print in one line the total number of testees. Then print the final ranklist in the following format:
registration_number final_rank location_number local_rank
The locations are numbered from 1 to N. The output must be sorted in nondecreasing order of the final ranks. The testees with the same score must have the same rank, and the output must be sorted in nondecreasing order of their registration numbers.
Sample Input:
2
5
1234567890001 95
1234567890005 100
1234567890003 95
1234567890002 77
1234567890004 85
4
1234567890013 65
1234567890011 25
1234567890014 100
1234567890012 85
Sample Output:
9
1234567890005 1 1 1
1234567890014 1 2 1
1234567890001 3 1 2
1234567890003 3 1 2
1234567890004 5 1 4
1234567890012 5 2 2
1234567890002 7 1 5
1234567890013 8 2 3
1234567890011 9 2 4#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Stu {
string id;
int score;
int frank;
int lrank;
int lonum;
} a[50000];
bool cmp(Stu s1, Stu s2) {
return s1.score == s2.score ? s1.id < s2.id : s1.score > s2.score;
}
int main() {
int n, k, total = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> k;
for (int j = total + 1; j <= k + total; j++) {
cin >> a[j].id >> a[j].score;
a[j].lonum = i;
}
sort(a + total + 1, a + total + k + 1, cmp);
int t = 2;
a[total + 1].lrank = 1;
for (int j = total + 2; j <= k + total; j++) {
if (a[j].score == a[j - 1].score) {
a[j].lrank = a[j - 1].lrank;
} else {
a[j].lrank = t;
}
t++;
}
total += k;
}
sort(a + 1, a + total + 1, cmp);
int t = 2;
a[1].frank = 1;
for (int i = 2; i <= total; i++) {
if (a[i].score == a[i - 1].score) {
a[i].frank = a[i - 1].frank;
} else {
a[i].frank = t;
}
t++;
}
cout << total << endl;
for (int i = 1; i <= total; i++) {
cout << a[i].id << ' ' << a[i].frank << ' ' << a[i].lonum << ' ' << a[i].lrank << endl;
}
return 0;
}
边栏推荐
- 券商经理的开户二维码开户买股票安全吗?有谁知道啊
- 1030 Travel Plan
- Jinyuan's high-end IPO was terminated: it was planned to raise 750million Rushan assets and Liyang industrial investment were shareholders
- One to one relationship
- Workflow automation low code is the key
- openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
- 1029 Median
- 中金证券经理给的开户二维码安全吗?找谁可以开户啊?
- GIS remote sensing R language learning see here
- 云笔记到底哪家强 -- 教你搭建自己的网盘服务器
猜你喜欢

Introduction to deep learning and neural networks

International School of Digital Economics, South China Institute of technology 𞓜 unified Bert for few shot natural language understanding

The IPO of Yuchen Airlines was terminated: Guozheng was proposed to raise 500million yuan as the major shareholder

数组练习 后续补充

Jinyuan's high-end IPO was terminated: it was planned to raise 750million Rushan assets and Liyang industrial investment were shareholders

Crawl national laws and Regulations Database

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律

如何利用 RPA 实现自动化获客?

昱琛航空IPO被终止:曾拟募资5亿 郭峥为大股东

基于STM32F103ZET6库函数外部中断实验
随机推荐
Is it safe to buy stocks and open an account on the account opening link of the securities manager? Ask the great God for help
Vs code runs "yarn run dev" and reports "yarn": the file XXX cannot be loaded
Substrate及波卡一周技术更新速递 20220425 - 20220501
Four years of College for an ordinary graduate
Leetcode 1381. 设计一个支持增量操作的栈
PCB线路板蛇形布线要注意哪些问题?
1027 Colors in Mars
什么是SSR/SSG/ISR?如何在AWS上托管它们?
今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
華大單片機KEIL報錯_WEAK的解决方案
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
通过 G1 GC Log 重新认识 G1 垃圾回收器
GIS遥感R语言学习看这里
聊聊毕业季
Tupu digital twin intelligent energy integrated management and control platform
One week technical update express of substrate and Boca 20220425 - 20220501
Gartner聚焦中国低代码发展 UniPro如何践行“差异化”
CDGA|交通行业做好数字化转型的核心是什么?
(LC)46. 全排列
How to encapsulate and call a library