比赛 20121106 评测结果 WWWWWWEEEEEE
题目名称 H 指数因子 最终得分 0
用户昵称 duwei 运行时间 0.011 s
代码语言 Pascal 内存使用 0.19 MiB
提交时间 2012-11-06 10:02:49
显示代码纯文本
program publish;
  var n,i,j,l,k,x:longint;
      m:array[0..101] of string;
      a,b,ans:array[0..101] of longint;
  procedure msort(l,r:longint);
    var i,j,k:longint;d:string;
    begin
      for i:=l to r do
        begin
         for j:=r downto i do
           if m[j]<m[j+1] then
             begin
              d:=m[j];m[j]:=m[j+1];m[j+1]:=d;
              k:=a[j];a[j]:=a[j+1];a[j+1]:=k;
             end;
        end;
    end;
  procedure qsort(l,r:longint);
    var i,j,k,mid:longint;
    begin
      i:=l;j:=r;mid:=a[(i+j)shr 1];
      repeat
        while a[i]<mid do inc(i);
        while a[j]>mid do dec(j);
        if i<=j then
          begin
            k:=a[i];a[i]:=a[j];a[j]:=k;
          inc(i);dec(j);
          end;
      until i>j;
      if i<r then qsort(i,r);
      if j>l then qsort(l,j);
    end;
  procedure sort(l,r:longint);
    var i,j,k,mid:longint;
    begin
      i:=l;j:=r;mid:=a[(i+j)shr 1];
      repeat
        while a[i]>mid do inc(i);
        while a[j]<mid do dec(j);
        if i<=j then
          begin
            k:=a[i];a[i]:=a[j];a[j]:=k;
          inc(i);dec(j);
          end;
      until i>j;
      if i<r then qsort(i,r);
      if j>l then qsort(l,j);
    end;
  begin
    assign(input,'publish.in');reset(input);
    assign(output,'publish.out');rewrite(output);
    readln(n);
    for i:=1 to n do
      readln(m[i]);
    for i:=1 to n do
      for j:=1 to n do
        begin
          read(x);
          if x=1 then inc(a[j]);
        end;
    msort(1,n);
    k:=0;l:=1;
    for i:=1to n+1 do
      if m[i]=m[i-1] then inc(b[k]) else begin inc(k);inc(b[k]);end;
    dec(k);
    for i:=1 to k do
      begin
       l:=l+b[i];
       qsort(l-b[i],l-1);
      end;
    l:=1;
    for i:=1 to k do
      begin
        l:=l+b[i];
        for j:=l-1 downto l-b[i] do
          if  b[i]-j+1<=a[j] then ans[i]:=b[i]-j+1;
      end;
    sort(1,k);
    l:=1;
    for i:=1 to k do
       begin
         l:=l+b[i];
         writeln(m[l-1],' ',ans[i]);
       end;
    close(input);close(output);
  end.