- 异或路径(xorpath)
蒟蒻在线求助
- @ 2026-4-4 22:30:03
#include <bits/stdc++.h>
using namespace std;
const int maxn = 25;
unsigned long long n, m, k; int ans = 0;
unsigned long long a[maxn][maxn];
bool vis[maxn][maxn];
void dfs(unsigned int x, unsigned int y, unsigned long long xorans);
int main(void) {
freopen("xorpath.in", "r", stdin);
freopen("xorpath.out", "w", stdout);
cin >> n >> m >> k;
for (unsigned int i = 1;i <= n;i++) {
for (unsigned int j = 1;j <= m;j++) {
cin >> a[i][j];
}
}
dfs(1, 1, a[1][1]);
cout << ans << '\n';
return 0;
}
void dfs(unsigned int x, unsigned int y, unsigned long long xorans) {
if (xorans == k && x == n && y == m) {
ans++; return;
}
if (x > n || y > m) return;
if (x < 1 || y < 1) return;
if (vis[x][y]) return;
vis[x][y] = true;
dfs(x + 1, y, xorans ^ a[x + 1][y]);
dfs(x, y + 1, xorans ^ a[x][y + 1]);
vis[x][y] = false;
}
时间炸了
0 条评论
目前还没有评论...
信息
- ID
- 582
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- 递交数
- 56
- 已通过
- 6
- 上传者