| 比赛 | 
    20101101 | 
    评测结果 | 
    AATTTTTTEA | 
    | 题目名称 | 
    漂亮字串 | 
    最终得分 | 
    30 | 
    | 用户昵称 | 
    make | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    Pascal | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2010-11-01 20:05:05 | 
显示代码纯文本
program bs;
var
  counto,countx,maxo,maxx,sp,max:longint;
  f1,f2:text;
procedure init;
begin
 assign(f1,'bs.in'); reset(f1);
 assign(f2,'bs.out'); rewrite(f2);
end;
procedure dfs(counto,countx,oo,xx:longint);
var r:longint;
begin
 if sp>max then max:=sp;
  for r:=1 to 2 do begin
   if r=1 then begin
    if (oo<maxo)and(counto>0) then begin
     inc(sp);
     dfs(counto-1,countx,oo+1,0);
     dec(sp);
    end
   end;
   if r=2 then begin
    if (xx<maxx)and(countx>0) then begin
     inc(sp);
     dfs(counto,countx-1,0,xx+1);
     dec(sp);
    end
   end;
  end;
end;
procedure play;
begin
 repeat
  max:=0;
  readln(f1,counto,countx,maxo,maxx);
  dfs(counto,countx,0,0);
  writeln(f2,max);
 until eof(f1);
 close(f2);
end;
begin
 init;
 play;
end.