社区讨论
都说洛谷数据水,vijos深搜过了,这却过不了,只能递推
P1002[NOIP 2002 普及组] 过河卒参与者 5已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @mi4hlcbb
- 此快照首次捕获于
- 2025/11/18 19:25 4 个月前
- 此快照最后确认于
- 2025/11/18 19:25 4 个月前
CPP
var
n,m,c,d,i,j:longint;
a:array[0..20,0..20] of int64;
b:array[0..20,0..20] of boolean;
function go(n,m:longint):longint;
begin
if a[n,m]=0 then exit;
if a[n,m]<>0 then go:=a[n,m]
else if (n-1>=0) and (m-1>=0) then go:=go(n-1,m)+go(n,m-1);
end;
procedure jq(x,y:longint);
begin
fillchar(b,sizeof(b),true);
b[x,y]:=false;
if x-2>=0 then begin
if y-1>=0 then b[x-2,y-1]:=false;
if y+1<=m then b[x-2,y+1]:=false;
end;
if x+2<=n then begin
if y-1>=0 then b[x+2,y-1]:=false;
if y+1<=m then b[x+2,y+1]:=false;
end;
if y-2>=0 then begin
if x-1>=0 then b[x-1,y-2]:=false;
if x+1<=n then b[x+1,y-2]:=false;
end;
if y+2<=m then begin
if x-1>=0 then b[x-1,y+2]:=false;
if x+1<=n then b[x+1,y+2]:=false;
end;
end;
begin
read(n,m,c,d);
jq(c,d);
for i:=1 to n do if b[i,0]=false then break else a[i,0]:=1;
for i:=1 to m do if b[0,i]=false then break else a[0,i]:=1;
for i:=1 to n do
for j:=1 to m do
if b[i,j]<>false then a[i,j]:=a[i-1,j]+a[i,j-1];
write(a[n,m]);
end.
回复
共 4 条回复,欢迎继续交流。
正在加载回复...