1025. PAT Ranking (25)
来源:互联网 发布:网络直播方案 编辑:程序博客网 时间:2024/05/17 10:05
1025. PAT Ranking (25)
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:251234567890001 951234567890005 1001234567890003 951234567890002 771234567890004 8541234567890013 651234567890011 251234567890014 1001234567890012 85Sample Output:
91234567890005 1 1 11234567890014 1 2 11234567890001 3 1 21234567890003 3 1 21234567890004 5 1 41234567890012 5 2 21234567890002 7 1 51234567890013 8 2 31234567890011 9 2 4
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;struct node{ long long id; int socre; int group; int finlrank; int localrank;};int cmp1(node a, node b){ if(a.socre != b.socre) return a.socre>b.socre; return a.id < b.id;}int main(){ int k,n,m; cin>>k; vector<node>per; for(int i = 1; i <= k; i++) { cin>>n; vector<node>tmp(n); for(int j = 0; j < n; j++) { cin>>tmp[j].id>>tmp[j].socre; tmp[j].group = i; } sort(tmp.begin(), tmp.end(), cmp1); tmp[0].localrank = 1; per.push_back(tmp[0]); for(int j = 1; j < n; j++) { tmp[j].localrank = (tmp[j].socre == tmp[j - 1].socre) ? tmp[j - 1].localrank:j+1; per.push_back(tmp[j]); } } sort(per.begin(), per.end(),cmp1); per[0].finlrank = 1; for(int i = 1; i < per.size(); i++) { per[i].finlrank = (per[i].socre == per[i- 1].socre) ? per[i - 1].finlrank:i+1; } cout<<per.size()<<endl; for(int i = 0; i < per.size(); i++) { printf("%013lld %d %d %d\n",per[i].id,per[i].finlrank,per[i].group,per[i].localrank); }}
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- 1025. PAT Ranking (25)
- Codeforces 387D George and Interesting Graph【思维+二分匹配】
- UVA 1354 Mobile Computing(暴力)
- Face++ 人脸识别,身份识别集成
- FPGA多时钟处理应用
- 单例模式
- 1025. PAT Ranking (25)
- dlib 02 dlib人脸关键点检测器训练
- 机房重构---添加删除用户(删除DataGridView选定行,更新数据库)
- 记录自己微信开发趟过的那些坑
- java类加载器笔记
- Tiled Map Editor(三)
- mysql索引的操作
- bzoj1180OTOCI 动态树(Linked-Cut-Tree)
- 基于S3C2440的UART传输小结