3、4点TLE,有谁知道这是为什么啊?
查看原帖
3、4点TLE,有谁知道这是为什么啊?
417994
wbstc12138楼主2022/4/3 11:01
#include <bits/stdc++.h>
using namespace std;
int a[30][30]={0};
int n=0;
long long  f(int b,int c) {
	if (a[b][c]==0) {
//		cout << b <<" "<<c <<endl; 
		if (c==2 && b==2) return 1;
		else if (b==2) return f(b,c-1);
		else if (c==2) return f(b-1,c);
		else return  f(b,c-1)+f(b-1,c);
	}
	else return 0;
}
int main () {
	int b,c,x,y;
	long long z=0;
	cin >> b >>c >>x >>y;
	b+=2;c+=2,x+=2,y+=2;
	a[x][y]=1;
	a[x-2][y-1]=1;
	a[x-1][y-2]=1;
	a[x-2][y+1]=1;
	a[x-1][y+2]=1;
	a[x+1][y+2]=1;
	a[x+2][y+1]=1;
	a[x+1][y-2]=1;
	a[x+2][y-1]=1;
	z =f(b,c);
	cout <<z;

	return 0;
} //for (x=0;x<=b;x++) {
//	for (y=0;y<=c;y++)
//		cout <<a[x][y] <<" ";
//	cout <<endl;	
//} 
//for (int x=0;x<=b;x++) {
//	for (int y=0;y<=c;y++)
//		cout <<a[x][y] <<" ";
//	cout <<endl;
//}
2022/4/3 11:01
加载中...