全红求调
查看原帖
全红求调
1327857
Endless_summer楼主2024/8/13 11:38

没看出来哪里有问题 悬关

#include<bits/stdc++.h>
using namespace std;
long long chess[25][25]; 
queue < pair<int,int> > Q;
int main(){
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	chess[x][y]=-1;
	if(0<=x+2&&x+2<=m&&0<=y+1&&y+1<=n) chess[x+2][y+1]=-1;if(0<=x+2&&x+2<=m&&0<=y-1&&y-1<=n) chess[x+2][y-1]=-1;	
	if(0<=x-2&&x-2<=m&&0<=y+1&&y+1<=n) chess[x-2][y+1]=-1;if(0<=x-2&&x-2<=m&&0<=y-1&&y-1<=n) chess[x-2][y-1]=-1;	
	if(0<=x+1&&x+1<=m&&0<=y+2&&y+2<=n) chess[x+1][y+2]=-1;if(0<=x+1&&x+1<=m&&0<=y-2&&y-2<=n) chess[x+1][y-2]=-1;	
	if(0<=x-1&&x-1<=m&&0<=y+2&&y+2<=n) chess[x-1][y+2]=-1;if(0<=x-1&&x-1<=m&&0<=y-2&&y-2<=n) chess[x-1][y-2]=-1;	
	chess[0][0]=1;
	Q.push({0,0});
	while(!Q.empty()){
		int p=Q.front().first,q=Q.front().second;
		Q.pop();
		if(chess[p][q+1]!=-1){
			if(q+1>m) continue;
			chess[p][q+1]+=chess[p][q];
			Q.push({p,q+1});
		}
		if(chess[p+1][q]!=-1){
			if(p+1>n) continue;
			chess[p+1][q]+=chess[p][q];
			Q.push({p+1,q+1});
		}
	}
	if(chess[n][m==-1]) cout<<0;
	cout<<chess[n][m];
	return 0;
}
2024/8/13 11:38
加载中...