Section 1.4 Mother's Milk

时间:2023-03-08 23:25:20
Section 1.4 Mother's Milk

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

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

program milk3_;
var markt:array[..] of integer;
marka:array[..] of integer;
i,a,b,c,a0,b0,c0,head,tail:longint;
qa,qb,qc:array[..] of integer;
s:string;flag:boolean;
procedure judge(r:integer);
begin
if a= then marka[c]:=;
end; procedure add(a,b,c:integer);
begin
if markt[a*+b*+c]= then exit;
inc(tail);
qa[tail]:=a;qb[tail]:=b;qc[tail]:=c;
markt[a*+b*+c]:=;
end; begin
assign(input,'milk3.in');reset(input);
assign(output,'milk3.out');rewrite(output);
fillchar(markt,sizeof(markt),);
fillchar(marka,sizeof(marka),);
readln(a0,b0,c0);
head:=;tail:=;
qa[]:=;qb[]:=;qc[]:=c0;
while (head<=tail) and (tail<=) 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(,a+b,c);
if a+c>c0 then add(a+c-c0,b,c0) else add(,b,a+c);
if b+a>a0 then add(a0,a+b-a0,c) else add(a+b,,c);
if b+c>c0 then add(a,b+c-c0,c0) else add(a,,b+c);
if c+a>a0 then add(a0,b,a+c-a0) else add(a+c,b,);
if c+b>b0 then add(a,b0,b+c-b0) else add(a,b+c,);
inc(head);
end;
flag:=false;
for i:= to c0 do
if marka[i]= then
begin
if flag=false then flag:=true else write(' ');
write(i);
end;
writeln;
close(input);close(output);
end.

milk3