Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁救我?快疯了

Posted by Lucifer at 2003-11-10 12:20:46 on Problem 1002
PROGRAM Lucifer1002;
Type themap=record
         name:string;
         total:0..100;
         end;
Var Number:integer;
    map:array[1..100000] of themap;
    now:word;
Procedure Init;
begin
  readln(Number);
end;
Procedure Solve;
var temp:integer;
    s:string;
function Stand(c:char):integer;
begin
  if not (c in ['0'..'9']) then
  begin
  if ord(c)<82 then
     case (ord(c)+1) div 3 of
      22:Stand:=2;
      23:Stand:=3;
      24:Stand:=4;
      25:Stand:=5;
      26:Stand:=6;
      27:Stand:=7;
     end
               else
     case (ord(c) div 3) of
      27:Stand:=7;
      28:Stand:=8;
      29:Stand:=9;
     end;
  end
  else
  stand:=0;
end;
function translate(sth:string):string;
var tempii:integer;
    tempss,tempsss:string;
begin
  tempss:='';
  for tempii:=1 to length(sth) do
  begin
    if sth[tempii]<>'-' then
    begin
      if (stand(sth[tempii])<>0) then str(stand(sth[tempii]),tempsss)
                  else tempsss:=sth[tempii];
      tempss:=tempss+tempsss;
    end;
  end;
  translate:=tempss;
end;
procedure check(sth:string);
var tempi:integer;
    find:boolean;
begin
  find:=false;
  for tempi:=1 to now Do
      begin
      if map[tempi].name=translate(sth) then
       begin
       inc(map[tempi].total);
       find:=true;
       end;
      end;
  if find=false then
     begin
       inc(now);
       map[now].name:=translate(sth);
       map[now].total:=1;
     end;
end;
begin
  now:=0;
  for temp:=1 to number do
  begin
    readln(s);
    check(s);
  end;
end;
Procedure Out;
var temp,tempi:integer;
function smaller(stha1,stha2:string):boolean;
var tempiii:integer;
begin
  smaller:=false;
  tempiii:=1;
  while (tempiii<8) and (stha1[tempiii]=stha2[tempiii]) do
  inc(tempiii);
  if ord(stha1[tempiii])<ord(stha2[tempiii]) then
  smaller:=true;

end;
procedure changethem;
var temps:string;
    temptotal:integer;
begin
  temps:=map[tempi].name;
  temptotal:=map[tempi].total;
  map[tempi].name:=map[tempi+1].name;
  map[tempi].total:=map[tempi+1].total;
  map[tempi+1].name:=temps;
  map[tempi+1].total:=temptotal;

end;
begin
  for temp:=1 to now-1 do
  begin
    for tempi:=1 to now-1 do
    begin
      if smaller(map[tempi+1].name,map[tempi].name) then
         ChangeThem;
    end;
  end;
  for temp:=1 to now do
      if map[temp].total<>1 then
      begin
      insert('-',map[temp].name,4);
      writeln(map[temp].name,' ',map[temp].total);
      end;


end;
BEGIN
  Init;
  Solve;
  Out;
END.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator