40pts求调!!!后三个点TLE了
查看原帖
40pts求调!!!后三个点TLE了
746738
ychyyx楼主2024/8/18 22:59
#include <iostream>
using namespace std;
const int N = 1005;
int n, m;
int fx, fy;

int x1[2] = {0, 1};
int y11[2] = {1, 0};
bool b[N][N];
int ans;
void dfs(int x, int y) {
	b[x][y] = 1;
	if (x == n && y == n) {
		ans++;
		b[x][y] = 0;
		return ;
	} else {
		for (int i = 0; i < 2; i++) {
			int xx = x + x1[i];
			int yy = y + y11[i];
			if (xx >= 1 && yy >= 1 && xx <= n && yy <= n && b[xx][yy] == 0) {
				dfs(xx, yy);
				b[x][y] = 0;
			}
		}
	}
}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> fx >> fy;
		b[fx][fy] = 1;
	}
	dfs(1, 1);
	cout << ans % 100003;
	return 0;
}
2024/8/18 22:59
加载中...