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

手测原始数据40组,无错误。仍然wa.

Posted by The_Dawn at 2011-05-01 18:57:03 on Problem 2176
type
  rec=record
    p,opp:longint;
  end;

var
  i,j,k,l,len,t:longint;
  s,s1,s2,ts:string;
  f:array[1..101,1..101]of longint;
  link:array[1..101,1..101]of rec;

function calc(x:longint):longint;
  begin
    if x<10 then exit(1);
    exit(2);
  end;

procedure print(h,t:longint);
  var
    op,pp,i:longint;
  begin
    op:=link[h,t].opp;pp:=link[h,t].p;
    if pp=0 then
      begin
        for i:=h to t do write(s[i]);
        exit;
      end;
    if op=1 then
      begin
        print(h,pp);
        print(pp+1,t);
      end;
    if op=2 then
      begin
        write((t-h+1)div(pp-h+1));
        write('(');
        print(h,pp);
        write(')');
      end;
  end;

begin
  readln(s);len:=length(s);
  for i:=1 to len do
    for j:=i to len do f[i,j]:=j-i+1;
  for i:=1 to len do f[i,i]:=1;
  for l:=2 to len do
    for i:=1 to len-l+1 do
      begin
        j:=i+l-1;
        s2:=copy(s,i,j-i+1);
        for k:=i to j-1 do
          if f[i,k]+f[k+1,j]<f[i,j] then
            begin
              f[i,j]:=f[i,k]+f[k+1,j];
              with link[i,j] do
                begin
                  p:=k;
                  opp:=1;
                end;
            end;
        for k:=i to j-1 do
          if ((j-i+1)mod(k-i+1)=0) then
            begin
              t:=0;
              s1:=copy(s,i,k-i+1);ts:=s1;
              while (s1<>s2)and(length(s1)<=length(s2)) do begin s1:=s1+ts;inc(t);end;
              if (s1=s2)and(f[i,j]>f[i,k]+2+calc(t)) then
                begin
                  f[i,j]:=f[i,k]+2+calc(t);
                  with link[i,j] do
                    begin
                      p:=k;
                      opp:=2;
                    end;
                end;
            end;
      end;
  print(1,len);
  writeln;
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