社区讨论
为什么0分
P1002[NOIP 2002 普及组] 过河卒参与者 3已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @lo2f6mza
- 此快照首次捕获于
- 2023/10/23 12:50 2 年前
- 此快照最后确认于
- 2023/10/23 12:50 2 年前
测试数据6 6 3 3可以啊
CPP#include<iostream>
#include<cstring>
using namespace std;
long long num=1,n,m,x,y;
bool cant[21][21];
void dfs(int a,int b)
{
bool ok=false;
if(a+1<=n&&!cant[a+1][b])
{
dfs(a+1,b);
ok=true;
}
if(b+1<=m&&!cant[a][b+1])
{
if(ok)num++;
dfs(a,b+1);
}
else if(a+1<n&&b+1<m)--num;
}
int main()
{
cin>>n>>m>>x>>y;
n+=2;
m+=2;
x+=2;
y+=2;
cant[x+1][y+2]=true;
cant[x+2][y+1]=true;
cant[x-2][y+1]=true;
cant[x+1][y-2]=true;
cant[x-1][y+2]=true;
cant[x+2][y-1]=true;
cant[x-2][y-1]=true;
cant[x-1][y-2]=true;
//cant[x][y]=true;
dfs(2,2);
cout<<num;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...