比赛 20121106 评测结果 WWAWAWWWWWWW
题目名称 H 指数因子 最终得分 16
用户昵称 极寒之魇 运行时间 0.004 s
代码语言 Pascal 内存使用 0.23 MiB
提交时间 2012-11-06 09:41:07
显示代码纯文本
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;

procedure qsort(l,r:longint);
   var mid,i,j:longint;
       temp:ar;
   begin
   mid:=ed[(l+r) div 2].h;
   i:=l; j:=r;
   repeat
   while ed[i].h>mid  do inc(i);
   while ed[j].h<mid  do dec(j);
   if i<=j then begin
   if ed[i].h=ed[j].h then
   begin
   if ed[i].names>ed[j].names then
   begin temp:=ed[i]; ed[i]:=ed[j]; ed[j]:=temp; end; end else begin
    temp:=ed[i]; ed[i]:=ed[j]; ed[j]:=temp;
    end;
    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:=1;
   while i<atr[ed[k].a[i]] do inc(i);
   if i=1 then if atr[ed[k].a[1]]=0 then i:=0;
   ed[k].h:=i;
   end;
  qsort(1,x);
  for i:=1 to x do
   writeln(ed[i].names,' ',ed[i].h);
  close(output);
  end.