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.
题外话:我帮你整理了包括 AI 写作、绘画、视频(自媒体制作)零门槛 AI 课程 + 国内可直接顺畅使用的软件。想让自己快速用上 AI 工具来降本增效,辅助工作和生活?限时报名。
© 转载需附带本文链接,依据 CC BY-NC-SA 4.0 发布。