Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define llu long long unsigned
- using namespace std;
- llu n, m, k;
- llu matrix[21][21];
- map<llu, llu> meet[21][21];
- void dfs_crescente(int i, int j, int x){
- if (i + j == (n + m) / 2 - 1){
- meet[i][j][x ^ matrix[i][j]]++;
- }
- if (i + 1 < n){
- dfs_crescente(i + 1, j, x ^ matrix[i][j]);
- }
- if (j + 1 < m){
- dfs_crescente(i, j + 1, x ^ matrix[i][j]);
- }
- }
- llu cont = 0;
- void dfs_decrescente(int i, int j, int x){
- if (i + j == (n + m) / 2 - 1){
- cont += meet[i][j][x ^ k];
- }
- if (i - 1 >= 0){
- dfs_decrescente(i - 1, j, x ^ matrix[i][j]);
- }
- if (j - 1 >= 0){
- dfs_decrescente(i, j - 1, x ^ matrix[i][j]);
- }
- }
- int main(){
- cin >> n >> m >> k;
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++){
- cin >> matrix[i][j];
- }
- }
- dfs_crescente(0, 0, 0);
- dfs_decrescente(n - 1, m - 1, 0);
- cout << cont << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement