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

我怎么会WA啊?在机器上测试是对的啊,希望大家帮帮忙啊

Posted by Lightning at 2003-08-15 10:23:18 on Problem 1002
program pku1002;
var
  a:array[1.1000] of string[15];
  b:array[1..1000] of string[12];
  c:array['A'..'Y'] of '2'..'9';
  d:array[1..1000] of integer;
  ch:char; s:string;
  n,i,j,k,m:integer;
begin
  j:=2;
  for ch:='A' to 'O' do
    begin
      inc(j);
      c[ch]:=chr(j div 3 +1+ord('0'));
    end;
  c['P']:='7'; c['R']:='7'; c['S']:='7';j:=j+3;
  for ch:='T' to 'Y' do
    begin
      inc(j);
      c[ch]:=chr(j div 3 +1+ord('0'));
    end;
  readln (n);
  for i:=1 to n do
    begin
      readln (a[i]);
      for j:=1 to length(a[i]) do
        if a[i,j]<>'-' then if (a[i,j]>='A') and  (a[i,j]<'Z') then b[i]:=b[i]+c[a[i,j]]
        else b[i]:=b[i]+a[i,j];
      insert('-',b[i],4);
    end;
  m:=0;
  for i:=1 to n-1 do
    begin
      k:=1;
      for j:=i+1 to n do
        if b[i]<>' ' then if b[i]=b[j] then begin inc(k); b[j]:=' '; end;
      if k>1 then begin inc(m);b[m]:=b[i]; d[m]:=k; end;
    end;
  for i:=1 to m-1 do
    begin
      k:=i;
      for j:=i+1 to m do
        if b[k]>b[j] then k:=j;
      if k<>i then begin
                     s:=b[k];
                     b[k]:=b[i];
                     b[i]:=s;
                     n:=d[k];
                     d[k]:=d[i];
                     d[i]:=n;
                   end;
   end;
   if m=0 then writeln ('No duplicates.') else
   for i:=1 to m do
     writeln (b[i],' ',d[i]);
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