比赛 20120420 评测结果 AAAAAAT
题目名称 昵称 最终得分 85
用户昵称 wo shi 刘畅 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2012-04-20 08:45:54
显示代码纯文本
var
  j,i,now,time,t,n:longint;
  s:array[0..200000]of string;

procedure sort(l,r:longint);
var
  i,j:longint;
  x,y:string;
begin
  i:=l;
  j:=r;
  x:=s[(l+r) div 2];
  repeat
    while s[i]<x do inc(i);
    while x<s[j] do dec(j);
    if i<=j then
    begin
      y:=s[i];
      s[i]:=s[j];
      s[j]:=y;
      inc(i);
      dec(j);
    end;
  until i>j;
  if i<r then sort(i,r);
  if l<j then sort(l,j);
end;

begin
  assign(input,'nickname.in'); reset(input);
  assign(output,'nickname.out'); rewrite(output);
  readln(t);
  for time:=1 to t do
  begin
    readln(n);
    for i:=1 to n do
    begin
      readln(s[i]);
      for j:=1 to length(s[i]) do
      if ord(s[i][j])<97 then s[i][j]:=chr(ord(s[i][j])+32);
    end;
    sort(1,n);
    now:=1;
    for i:=2 to n do
    if s[i]=s[i-1] then inc(now)
    else begin
      writeln(s[i-1],' ',now);
      now:=1;
    end;
    writeln(s[n],' ',now);
  end;
  close(input);
  close(output);
end.