CF1006F.Xor-Paths

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a rectangular grid of size n×mn \times m. Each cell has a number written on it; the number on the cell (i,ji, j) is ai,ja_{i, j}. Your task is to calculate the number of paths from the upper-left cell (1,11, 1) to the bottom-right cell (n,mn, m) meeting the following constraints:

  • You can move to the right or to the bottom only. Formally, from the cell (i,ji, j) you may move to the cell (i,j+1i, j + 1) or to the cell (i+1,ji + 1, j). The target cell can't be outside of the grid.
  • The xor of all the numbers on the path from the cell (1,11, 1) to the cell (n,mn, m) must be equal to kk (xor operation is the bitwise exclusive OR, it is represented as '^' in Java or C++ and "xor" in Pascal).

Find the number of such paths in the given grid.

有一个大小为 n×mn \times m 的矩形网格。每个格子中写有一个数字;格子 (i,j)(i, j) 中的数字为 ai,ja_{i, j}。你的任务是计算从左上角格子 (1,1)(1, 1) 到右下角格子 (n,m)(n, m) 的路径数量,要求满足以下约束条件:

  • 每次只能向右或向下移动。形式化地说,从格子 (i,j)(i, j) 出发,你只能移动到格子 (i,j+1)(i, j + 1) 或格子 (i+1,j)(i + 1, j)。目标格子不能超出网格边界。
  • 从格子 (1,1)(1, 1) 到格子 (n,m)(n, m) 的路径上所有数字的异或(xor)结果必须等于 kk(异或运算是按位异或,在 Java 或 C++ 中表示为 ^,在 Pascal 中表示为 xor)。

请找出给定网格中满足上述条件的路径数量。

输入格式

The first line of the input contains three integers nn, mm and kk (1n,m201 \le n, m \le 20, 0k10180 \le k \le 10^{18}) — the height and the width of the grid, and the number kk.

The next nn lines contain mm integers each, the jj-th element in the ii-th line is ai,ja_{i, j} (0ai,j10180 \le a_{i, j} \le 10^{18}).

输入的第一行包含三个整数 nnmmkk1n,m201 \le n, m \le 200k10180 \le k \le 10^{18})—— 分别表示网格的高度、宽度以及数字 kk

接下来的 nn 行,每行包含 mm 个整数;其中第 ii 行的第 jj 个元素为 ai,ja_{i, j}0ai,j10180 \le a_{i, j} \le 10^{18})。

输出格式

Print one integer — the number of paths from (1,11, 1) to (n,mn, m) with xor sum equal to kk.

输出一个整数——从 (1,1)(1, 1)(n,m)(n, m) 的路径数量,使得路径上所有点权值的异或和等于 kk

输入输出样例

  • 输入#1

    3 3 11
    2 1 5
    7 10 0
    12 6 4

    输出#1

    3
  • 输入#2

    3 4 2
    1 3 3 3
    0 3 3 2
    3 0 1 1

    输出#2

    5
  • 输入#3

    3 4 1000000000000000000
    1 3 3 3
    0 3 3 2
    3 0 1 1

    输出#3

    0

说明/提示

All the paths from the first example:

  • (1,1)(2,1)(3,1)(3,2)(3,3)(1, 1) \rightarrow (2, 1) \rightarrow (3, 1) \rightarrow (3, 2) \rightarrow (3, 3);
  • (1,1)(2,1)(2,2)(2,3)(3,3)(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (2, 3) \rightarrow (3, 3);
  • (1,1)(1,2)(2,2)(3,2)(3,3)(1, 1) \rightarrow (1, 2) \rightarrow (2, 2) \rightarrow (3, 2) \rightarrow (3, 3).

All the paths from the second example:

  • (1,1)(2,1)(3,1)(3,2)(3,3)(3,4)(1, 1) \rightarrow (2, 1) \rightarrow (3, 1) \rightarrow (3, 2) \rightarrow (3, 3) \rightarrow (3, 4);
  • (1,1)(2,1)(2,2)(3,2)(3,3)(3,4)(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (3, 2) \rightarrow (3, 3) \rightarrow (3, 4);
  • (1,1)(2,1)(2,2)(2,3)(2,4)(3,4)(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (2, 3) \rightarrow (2, 4) \rightarrow (3, 4);
  • (1,1)(1,2)(2,2)(2,3)(3,3)(3,4)(1, 1) \rightarrow (1, 2) \rightarrow (2, 2) \rightarrow (2, 3) \rightarrow (3, 3) \rightarrow (3, 4);
  • (1,1)(1,2)(1,3)(2,3)(3,3)(3,4)(1, 1) \rightarrow (1, 2) \rightarrow (1, 3) \rightarrow (2, 3) \rightarrow (3, 3) \rightarrow (3, 4).

第一个示例中的所有路径:

  • (1,1)(2,1)(3,1)(3,2)(3,3)(1, 1) \rightarrow (2, 1) \rightarrow (3, 1) \rightarrow (3, 2) \rightarrow (3, 3)
  • (1,1)(2,1)(2,2)(2,3)(3,3)(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (2, 3) \rightarrow (3, 3)
  • (1,1)(1,2)(2,2)(3,2)(3,3)(1, 1) \rightarrow (1, 2) \rightarrow (2, 2) \rightarrow (3, 2) \rightarrow (3, 3)

第二个示例中的所有路径:

  • (1,1)(2,1)(3,1)(3,2)(3,3)(3,4)(1, 1) \rightarrow (2, 1) \rightarrow (3, 1) \rightarrow (3, 2) \rightarrow (3, 3) \rightarrow (3, 4)
  • (1,1)(2,1)(2,2)(3,2)(3,3)(3,4)(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (3, 2) \rightarrow (3, 3) \rightarrow (3, 4)
  • (1,1)(2,1)(2,2)(2,3)(2,4)(3,4)(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (2, 3) \rightarrow (2, 4) \rightarrow (3, 4)
  • (1,1)(1,2)(2,2)(2,3)(3,3)(3,4)(1, 1) \rightarrow (1, 2) \rightarrow (2, 2) \rightarrow (2, 3) \rightarrow (3, 3) \rightarrow (3, 4)
  • (1,1)(1,2)(1,3)(2,3)(3,3)(3,4)(1, 1) \rightarrow (1, 2) \rightarrow (1, 3) \rightarrow (2, 3) \rightarrow (3, 3) \rightarrow (3, 4)

输入解题思路,AI测评打分。不知道怎么写?

首页