记录编号 541677 评测结果 AAAAAAAAAA
题目名称 [NOIP 2002]过河卒 最终得分 100
用户昵称 Gravatar夜莺 是否通过 通过
代码语言 C++ 运行时间 0.993 s
提交时间 2019-09-15 13:55:46 内存使用 13.66 MiB
显示代码纯文本
#include<cstdio>
#include<iostream>
using namespace std;
long long int y1[3]={0,1,0},x1[3]={0,0,1};
long long int a[21][21],x2,y2,maxx=0;
void ss(int x,int y){
	for(int i=1;i<=2;i++)
		if((a[y+y1[i]][x+x1[i]]==0)&&(y+y1[i]<=y2)&&(x+x1[i]<=x2)){
			x+=x1[i];
			y+=y1[i];
			if(x==x2&&y==y2){
				maxx++;
			}
			else ss(x,y);
			x-=x1[i];
			y-=y1[i];
			
		}
}
int main(){
	for(int i=0;i<=20;i++)
	for(int j=0;j<=20;j++)
	a[i][j]=0;
	long long int n,m,x,y;
	freopen("pj024.in","r",stdin);
	freopen("pj024.out","w",stdout);
	cin>>n>>m>>x>>y;
	x2=n;y2=m;
	a[y][x]=1;
	if(y+1<=m&&x+2<=n)a[y+1][x+2]=1;
	if(y+2<=m&&x+1<=n)a[y+2][x+1]=1;
	if(y+2<=m&&x-1>=0)a[y+2][x-1]=1;
	if(y+1<=m&&x-2>=0)a[y+1][x-2]=1;
	if(y-1>=0&&x-2>=0)a[y-1][x-2]=1;
	if(y-2>=0&&x-1>=0)a[y-2][x-1]=1;
	if(y-2>=0&&x+1<=n)a[y-2][x+1]=1;
	if(y-1>=0&&x+2<=n)a[y-1][x+2]=1;
	ss(0,0);
	cout<<maxx; 
}