记录编号 48766 评测结果 AAAAAAAWAAAA
题目名称 H 指数因子 最终得分 91
用户昵称 Gravatar极寒之魇 是否通过 未通过
代码语言 Pascal 运行时间 0.009 s
提交时间 2012-11-06 15:33:12 内存使用 0.23 MiB
显示代码纯文本
type ar=record
       a:array[0..100] of longint;
       names:string;
       h:longint;
       end;
var ed:array[1..100] of ar;
    atr:array[1..100] of longint;
    s:string;
    x,i,n,j,k:longint;
    c:char;

procedure editor(s:string);
    var i:longint;
    begin
    for i:=1 to x do
    if ed[i].names=s then  begin inc(ed[i].a[0]); ed[i].a[ed[i].a[0]]:=j; exit; end;
    inc(x); ed[x].names:=s; ed[x].a[0]:=1; ed[x].a[ed[x].a[0]]:=j;
    exit;
    end;
procedure swap(x,y:longint);
    var temp:longint;
    begin temp:=x; x:=y; y:=temp; end;

function bw(x,y:ar):boolean;
    begin
     if x.h>y.h then exit(true);
     if ((x.h=y.h) and (x.names<y.names)) then exit(true);
     exit(false);
     end;

procedure qsort(l,r:longint);
   var i,j:longint;
       temp,mid:ar;
   begin
   mid:=ed[(l+r) div 2];
   i:=l; j:=r;
   repeat
   while bw(ed[i],mid)  do inc(i);
   while bw(mid,ed[j]) do dec(j);
   if i<=j then begin
    temp:=ed[i]; ed[i]:=ed[j]; ed[j]:=temp;
    inc(i); dec(j);
   end;
   until i>j;
   if l<j then qsort(l,j);
   if i<r then qsort(i,r);
   end;

begin
  assign(input,'publish.in'); reset(input);
  assign(output,'publish.out'); rewrite(output);
  readln(n);
  for j:=1 to n do
  begin
  readln(s);
  editor(s);
  end;
  fillchar(atr,sizeof(atr),0);
  for i:=1 to n do
  begin
  for j:=1 to n do
   begin
   read(c);
   if c='1' then inc(atr[j]);
   end;
   readln;
  end;

  for k:=1 to x do
  for i:=1 to ed[k].a[0]-1 do
   for j:=1 to ed[k].a[0] do
    if atr[ed[k].a[i]]<atr[ed[k].a[j]] then swap(ed[k].a[i],ed[k].a[j]);

  for k:=1 to x do
   begin
   i:=0;
   while i<atr[ed[k].a[i+1]] do inc(i);
   ed[k].h:=i;
   end;
  qsort(1,x);
  for i:=1 to x do
   writeln(ed[i].names,' ',ed[i].h);
  close(output);
  end.