Problem descriptionpaper 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:
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 memory SOR, and H-index of 45 or higher cocould mean membership in the united states Emy of sciences.
You are to calculate the H-index for all the researchers in the list, base on the given information. inputthere 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-. though it wocould be common for one paper written by several authors, there wocould 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 cocould never cite itself. outputfor each scenario, output as same lines as the number of authors given. each line contains the author's name and his h-index. the list shoshould 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
4PeterPeterBobBob00001000110001000
Sample output
Peter 2Bob 0
// James's H-index indicates that James has at least H papers in his paper, this H paper references at least H times # 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 ++; // calculate the number of referenced 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 ++; // calculate the H-index (note a [I]. B is sorted in ascending order.) 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 ;}
H-index factor