USACO The Perfect Stall (stall4) 程序

TASK: stall4 LANG: PASCAL

Compiling… Compile: OK Executing… Test 1: TEST OK

\[0.000 secs, 248 KB\]

Test 2: TEST OK

\[0.000 secs, 244 KB\]

Test 3: TEST OK

\[0.000 secs, 248 KB\]

Test 4: TEST OK

\[0.011 secs, 244 KB\]

Test 5: TEST OK

\[0.000 secs, 248 KB\]

Test 6: TEST OK

\[0.000 secs, 244 KB\]

Test 7: TEST OK

\[0.011 secs, 244 KB\]

Test 8: TEST OK

\[0.011 secs, 244 KB\]

Test 9: TEST OK

\[0.011 secs, 244 KB\]

All tests OK. Your program (‘stall4’) produced all correct answers! This is your submission #3 for this problem. Congratulations!

{ ID:ceeji PROB:stall4 LANG:PASCAL } //By Ceeji //Date: 2009-4-20 //Type: Div 2 Graph Match //State: Accepted //Source: USACO stall4 Program stall4; Const fin=‘stall4.in’; fou=‘stall4.out’; maxn=200; Var n,m,i,j,p,g,ans:longint; can:array

\[1..maxn,1..maxn\]

of boolean; match:array

\[1..maxn\]

of longint; b:array

\[0..maxn\]

of boolean; Function find(p:longint):boolean; var i,j:longint; begin if (p=0) then exit(true); b

\[p\]

:=true; for i:=1 to n do begin if (can

\[p,i\]

)and(b

\[match\[i\]

]=false) then begin if find(match

\[i\]

) then begin match

\[i\]

:=p; exit(true); end; end; end; exit(false); end; begin assign(input,fin); reset(input); assign(output,fou); rewrite(output); readln(n,m); fillchar(can,sizeof(can),0); fillchar(match,sizeof(match),0); for i:=1 to n do begin read(p); for j:=1 to p do begin read(g); can

\[i,g\]

:=true; end; readln; end; close(input); ans:=0; for i:=1 to n do begin fillchar(b,sizeof(b),0); if find(i) then inc(ans); end; writeln(ans); close(output); end.

当前页阅读量为: