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:38:12 on Problem 3461
In Reply To:为何WA Posted by:frankvista at 2010-10-26 19:08:30
> var
>   n,i : longint;
>   s,t : ansistring;
>   next : array[1..100000] of longint;
> 
> procedure compute_next;
> var
>   k,q : integer;
> begin
>   k := 0; next[1] := 0;
>   for q := 2 to length(t) do begin
>     while (k > 0) and (t[q] <> t[k+1]) do k := next[k];
>     if t[q] = t[k+1] then inc(k);
>     next[q] := k;
>   end;
> end;
> 
> function kmp : longint;
> var
>   k,q : integer;
> begin
>   compute_next;
>   k := 0; kmp := 0;
>   for q := 1 to length(s) do begin
>     while (k > 0) and (s[q] <> t[k+1]) do k := next[k];
>     if s[q] = t[k+1] then inc(k);
>     if k = length(t) then begin
>       inc(kmp);
>       k := next[k];
>     end;
>   end;
> end;
> 
> begin
>   readln(n);
>   for i := 1 to n do begin
>     readln(t); readln(s);
>     writeln(kmp);
>   end;
> 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