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

Re:为何WA

Posted by wdqwang1 at 2012-04-04 21:42:12 on Problem 3461
In Reply To:Re:为何WA Posted by:wdqwang1 at 2012-04-04 21:38:12
var a:array[1..1000005]of char;
p:array[1..10005]of longint;
b:array[1..10005]of char;
t,ans,i,j,k,n,m:longint;
ch:char;
begin
readln(t);
for k:=1 to t do
  begin
    fillchar(p,sizeof(p),0);
    n:=0;m:=0;ans:=0;
    read(ch);
    while (ch>='A') and (ch<='Z') do
      begin
        inc(m);
        b[m]:=ch;
        read(ch);
      end;
    readln;
    read(ch);
    while (ch>='A') and (ch<='Z') do
      begin
        inc(n);
        a[n]:=ch;
        read(ch);
      end;
    readln;
    j:=0;
    for i:=2 to m do
      begin
        while (j>0) and (b[j+1]<>b[i]) do j:=p[j];
        if b[j+1]=b[i] then j:=j+1;
        p[i]:=j;
      end;
    j:=0;
    for i:=1 to n do
      begin
        while (j>0) and (b[j+1]<>a[i]) do j:=p[j];
        if b[j+1]=a[i] then inc(j);
        if j=m then
          begin
            inc(ans);
            j:=p[j];
          end;
       end;
     writeln(ans);
   end;
end.
我也不知为何WA啊

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