H-index因素

Problem Description

Paper quality and quantity have long been used to measure a research's scientific productivity and scientific impact. Citation, which is the total times a paper has been cited, is a common means to judge importance of a paper. However, with all these factors varying, a collegiate committee has problems when judging which research is doing better. For this reason, H-index is proposed and now widely used to combine the above factors and give accurate judgement. H-index is defined as:
A scientist has index h if h of [his] Np papers have at least h citations each, and the other(Np-h) papers have at most h citations each.
In other words, a scholar with an index of h has published h papers each of which has been cited by others at least h times. Note that H-index is always an integer. It's said that achiveing H-index of 18 means one is fully quality to be a professor, and H-index of 45 or higher could mean membership in the United States Academy of Sciences.
You are to calculate the H-index for all the researchers in the list, base on the given information.

Input

There are multiple scenarios in the input, terminated by a single zero(0).
Each of the scenarios begin with an integer N(1<=N<=100), means that there are N papers. N lines follow, each contain a string(not exceeding 20 characters long), representing the author of the corresponding paper, without white spaces in-between. Though it would be common for one paper written by several authors, there would be exactly one author of each of these papers. Finally, there are N lines of strings, containing '0's and '1's. If the j-th character in the i-th line is '1', it means the i-th paper cites the j-th paper. A paper could never cite itself.

Output

For each scenario, output as many lines as the number of authors given. Each line contains the author's name and his H-index. The list should be sorted first by H-index in descending order, than by name in alphabetic order(Actually, ASCII order. So 'B' is prior to 'a').
Output a blank line after each scenario.

Sample Input

4
Peter
Peter
Bob
Bob
0000
1000
1100
0100
0

Sample Output

Peter 2
Bob 0
//小明的H-index表示小明发表的论文中至少有H篇论文,这H篇论文每篇至少引用H次 
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
struct input{
	string s;
	int b;
}a[110];
struct output{
	string s;
	int b;
}c[110];
bool cmp(input x,input y)
{
	if(x.s==y.s) return x.b>y.b;
	else return x.s<y.s;
}
bool cm(output x,output y)
{
	if(x.b==y.b) return x.s<y.s;
	else return x.b>y.b;
}
int main()
{
	//freopen("a.txt","r",stdin);
	int n;
	while(cin>>n&&n)
	{
		int k,i,len,j;
		for(i=0;i<n;i++) 
		{
			cin>>a[i].s;  
			c[i].b=a[i].b=0;
		}  
		for(i=0;i<n;i++) 
		{
			char m[110];
			scanf("%s",m); 
			len=strlen(m); 
			while(len>0)
			{
				if(m[len-1]-'0'==1&&i!=len-1) a[len-1].b++;  //计算每篇论文被引用的数量 
			    len--;
			}
		}
		sort(a,a+n,cmp);          
		for(k=0,i=0;i<n;i=j)
		{
			for(j=i;a[i].s==a[j].s;j++)
			if(a[j].b>c[k].b) c[k].b++;       //计算H-index(注意a[i].b是按从大到小排序的) 
			c[k].s=a[i].s;
			k++;
		}
		sort(c,c+k,cm);
		for(i=0;i<k;i++) cout<<c[i].s<<' '<<c[i].b<<endl;
		printf("\n");
	}
	return 0;
}


版权声明:本文博客原创文章,博客,未经同意,不得转载。

posted @ 2015-08-09 10:36  hrhguanli  阅读(210)  评论(0编辑  收藏  举报