谷外题求助
  • 板块灌水区
  • 楼主Silver_winter
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/17 15:42
  • 上次更新2025/1/17 18:36:59
查看原帖
谷外题求助
1125069
Silver_winter楼主2025/1/17 15:42

信息学奥赛一本通p1196

爆零代码:

#include<bits/stdc++.h>
using namespace std;
int n;
int sum=0;
bool a[20][20];
void ss(int x,int y,int b){
	if(b==n){
		sum++;
		return;
	}
	a[x][y]=1;
	if(!a[x-1][y])ss(x-1,y,b+1);
	if(!a[x][y-1])ss(x,y-1,b+1);
	if(!a[x][y+1])ss(x,y+1,b+1);
}
int main(){
	cin>>n;
	ss(n-1,0,0);
	cout<<sum;
	return 0;
}
2025/1/17 15:42
加载中...