Section 1.4 Mother's Milk

又是一道怨念已久的题目0 0之前深搜写过广搜写过,怎么就是卡死,我还以为FP坏了重新装了一遍。今天偶尔翻起来,发现广搜忘记inc(head)了…简直哭瞎…

简单的广搜,分类比较多,不过不太要动脑子。至此Section 1.4完美完成。(喂,你开usaco账号都快一年了就做到1.4?6个Chapter什么时候才能做完?咦怎么6个Chapter了以前就五个吧……)

program milk3_2;
var markt:array[0..8000] of integer;
    marka:array[0..20] of integer;
    i,a,b,c,a0,b0,c0,head,tail:longint;
    qa,qb,qc:array[1..200] of integer;
    s:string;flag:boolean;
procedure judge(r:integer);
begin
  if a=0 then marka[c]:=1;
end;

procedure add(a,b,c:integer);
begin
  if markt[a*400+b*20+c]=1 then exit;
  inc(tail);
  qa[tail]:=a;qb[tail]:=b;qc[tail]:=c;
  markt[a*400+b*20+c]:=1;
end;

begin
  assign(input,'milk3.in');reset(input);
  assign(output,'milk3.out');rewrite(output);
  fillchar(markt,sizeof(markt),0);
  fillchar(marka,sizeof(marka),0);
  readln(a0,b0,c0);
  head:=1;tail:=1;
  qa[1]:=0;qb[1]:=0;qc[1]:=c0;
  while (head<=tail) and (tail<=200) do
    begin
      a:=qa[head];b:=qb[head];c:=qc[head];
      judge(head);
      if a+b>b0 then add(a+b-b0,b0,c) else add(0,a+b,c);
      if a+c>c0 then add(a+c-c0,b,c0) else add(0,b,a+c);
      if b+a>a0 then add(a0,a+b-a0,c) else add(a+b,0,c);
      if b+c>c0 then add(a,b+c-c0,c0) else add(a,0,b+c);
      if c+a>a0 then add(a0,b,a+c-a0) else add(a+c,b,0);
      if c+b>b0 then add(a,b0,b+c-b0) else add(a,b+c,0);
      inc(head);
    end;
  flag:=false;
  for i:=0 to c0 do
    if marka[i]=1 then
      begin
        if flag=false then flag:=true else write(' ');
        write(i);
      end;
  writeln;
  close(input);close(output);
end.
milk3
原文地址:https://www.cnblogs.com/Sky-Grey/p/3575829.html