40分求助 #1 WA,#3#4 TLE
查看原帖
40分求助 #1 WA,#3#4 TLE
977097
Li_Jiayu楼主2023/7/13 14:46
#include<bits/stdc++.h>
using namespace std;
long long n,m,x,y;
long long ans=0;
int cant[22+5][22+5];
void zhaolu(int a,int b){
	if(a==n&&b==m) {ans++;cout<<'<'<<ans<<'>'<<endl;}
	else{
		if((a+1<=n)&&(b<=m)&&(!cant[a+1][b])) {cout<<'('<<a+1<<','<<b<<')'<<' ';zhaolu(a+1,b);}
		if((b+1<=m)&&(a<=n)&&(!cant[a][b+1])) {cout<<'('<<a<<','<<b+1<<')'<<' ';zhaolu(a,b+1);}
	}
}
int main()
{
	cin>>n>>m>>x>>y;	
	cant[x][y]=1;//马本身 
	cant[x+1][y-2]=1;//P1
	cant[x+2][y-1]=1;//P2
	cant[x+2][y+1]=1;//P3
	cant[x+1][y+2]=1;//P4
	cant[x-1][y+2]=1;//P5
	cant[x-2][y+1]=1;//P6
	cant[x-2][y-1]=1;//P7
	cant[x-1][y-2]=1;//P8
	zhaolu(0,0);
	cout<<ans;
	return 0;
} 
2023/7/13 14:46
加载中...