- 浏览: 36666 次
- 性别:
- 来自: 杭州
最新评论
Sample Input:
2 5 1234567890001 95 1234567890005 100 1234567890003 95 1234567890002 77 1234567890004 85 4 1234567890013 65 1234567890011 25 1234567890014 100 1234567890012 85Sample 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 <vector> #include <iomanip> #include <map> #include <algorithm> using namespace std; struct STUDENT { string regnum; int score; int location; int totalrank; int locationrank; STUDENT() { score = 0; location = 0; totalrank = 0; locationrank = 0; } }; bool greatermark(const STUDENT& s1,const STUDENT& s2) { return s1.score > s2.score; } bool lessregnum(const STUDENT& s1,const STUDENT& s2) { return s1.regnum < s2.regnum; } bool sortByScore(STUDENT a,STUDENT b) { if(a.score != b.score) return a.score > b.score; return a.regnum < b.regnum; } int main() { int N; cin>>N; int i = 0; vector<STUDENT> VArray[100]; while(N--) { int K; cin>>K; vector<STUDENT> V; while(K--) { STUDENT stu; cin>>stu.regnum>>stu.score; stu.location = i + 1; V.push_back(stu); } sort(V.begin(), V.end(), sortByScore); int forword = -1; int irank = 0; int realrank = 0; vector<STUDENT>::iterator iter = V.begin(); while(iter != V.end()) { ++realrank; if (forword != (*iter).score) { irank = realrank; (*iter).locationrank = realrank; forword = (*iter).score; } else { (*iter).locationrank = irank; } iter++; } VArray[i] = V; i++; } vector<STUDENT> VSum; for (int i = 0; i < 100; i++) { VSum.insert(VSum.end(),VArray[i].begin(),VArray[i].end()); } sort(VSum.begin(), VSum.end(), sortByScore); int forword = -1; int irank = 0; int realrank = 0; vector<STUDENT>::iterator iter = VSum.begin(); while(iter != VSum.end()) { ++realrank; if (forword != (*iter).score) { irank = realrank; (*iter).totalrank = realrank; forword = (*iter).score; } else { (*iter).totalrank = irank; } iter++; } cout<<VSum.size(); cout.setf(ios::fixed); for (int i = 0; i < VSum.size(); i++) { cout<<endl; cout<<VSum[i].regnum<<" "<<VSum[i].totalrank<<" "<<VSum[i].location<<" "<<VSum[i].locationrank; } }
发表评论
-
PAT1013 Battle Over Cities
2012-11-29 23:59 774Sample Input 3 2 3 1 2 1 3 ... -
PAT1003 Emergency
2012-11-29 23:46 663Sample Input 5 6 0 2 1 2 1 ... -
PAT1041 Be Unique
2012-11-23 23:43 761找出只出现过一次的数,用各种排序必然超时,需要用数组做hash ... -
PAT1042 Shuffling Machine
2012-11-23 23:42 734扑克洗牌 #include < ... -
PAT1040 Longest Symmetric String
2012-11-23 23:41 960求最长回文子串 #include < ... -
PAT1036 Boys vs Girls
2012-11-23 23:41 716Sample Input 1: 3 Joe M Mat ... -
PAT1035 Password
2012-11-23 23:40 617Sample Input 1: 3 Team0000 ... -
PAT1031 Hello World for U
2012-11-22 23:54 656Sample Input: helloworld! S ... -
PAT1029 Median
2012-11-22 23:54 652用标准库的排序全部超时,需要自己实现,另外还不能用cin co ... -
PAT1028 List Sorting
2012-11-22 23:53 809用vector最后一个用例超时了。。。 Sample ... -
PAT1027 Colors in Mars
2012-11-22 23:52 624Sample Input 15 43 71 Samp ... -
PAT1023 Have Fun with Numbers
2012-11-21 23:55 687大数的相加 比较两个字符串中字符完全相同 Sa ... -
PAT1020 Tree Traversals
2012-11-21 23:54 653已知中序遍历 后序遍历,求层次遍历 Sample In ... -
PAT1019 General Palindromic Number
2012-11-21 23:53 538十进制转任意进制,并比较是否是回文数 Sample I ... -
PAT1037 Magic Coupon
2012-11-21 15:46 664Sample Input: 4 1 2 4 -1 ... -
PAT1038 Recover the Smallest Number
2012-11-20 23:52 1669由一道面试题改的 把数组排成最小的数 不同之处是这 ... -
PAT1024 Palindromic Number
2012-11-20 23:51 649Sample Input 1: 67 3 Sampl ... -
PAT1015 Reversible Primes
2012-11-19 23:51 771十进制转任意进制 假设十进制数为number,转 ... -
PAT1012 The Best Rank
2012-11-19 23:50 927四门功课,输出排名最高的是哪个 Sample Inpu ... -
PAT1011 World Cup Betting
2012-11-19 23:50 534Sample Input 1.1 2.5 1.7 1.2 ...
相关推荐
知识图谱推理方向的基础算法Path Ranking Algorithm详解
In plain, uncomplicated language, and using detailed examples to explain the key concepts, models, and algorithms in vertical search ranking, Relevance Ranking for Vertical Search Engines teaches ...
two different methods, including the SVM-based and RankingSVM-based methods, are presented to learn the mod-els with different example creation processes from the training set. Finally, the potential...
Multilabel classification via calibrated label ranking
Adapting Ranking SVM to Document Retrieval RankSVM
这里我们为大家介绍一种“基于贝叶斯后验优化的个性化排序算法”:Bayesian Personalized Ranking。 其本身并不优化用户对物品的评分,而只藉由评分来优化用户对物品的排序。按照论文的说法:it is a real ranking ...
BPR-Bayesian Personalized Ranking from Implicit Feedback 数据收集及随机抽取方面的资料
Inspired by the great success of information retrieval (IR) style keyword search on the web, keyword search on XML has emerged recently. The difference between text database and XML database results ...
Ranking-Based Classification of Heterogeneous Information Networks数据挖掘paper
2013年经典CVPR文章代码 Saliency Detection via Graph-Based Manifold Ranking
QoS-based Service,service ranking and selection,user's requirements
李航博士的Intro to Ranking
仿微信运动排行榜html
评级函数中其中RANK()、DENSE-RANK()、PERCENT-RANK()函数是比较常用的。
Google Scholar's Ranking Algorithm -- An Introductory Overview
The PageRank Citation Ranking-Bringing Order to the Web.pdf
Topic-sensitive_pagerank_A_context-sensitive_ranking_algorithm_for_web_search
个性化垂直搜索引擎与排序学习,下一代搜索引擎与移动应用核心
random_ranking.java
yahoo在kdd2016发布的搜索引擎相关性文档,此文档汇包含排序函数,语义匹配以及query改写相关内容