Tap here to switch tabs
Problem
Submissions

Problem: Count Paths With the Given XOR Value

med
30 min
Try to solve the Count Paths With the Given XOR Value problem.

Statement

You are given an m $ imes$ n integer matrix grid and an integer k.

You start at the top left cell (0,0)(0, 0) and want to reach the bottom right cell (m −1- 1, n −1- 1). From any cell, you can only move either down or right.

The XOR value of a path is the bitwise XOR sum of all elements along that path.

Return the total number of paths from (0,0)(0, 0) to (m −1- 1, n −1- 1) whose XOR value equals k. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq m ==== grid.length ≤300\leq 300

  • 1≤1 \leq n ==== grid[r].length ≤300\leq 300

  • 0≤0 \leq grid[r][c] <16< 16

  • 0≤0 \leq k <16< 16

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Paths With the Given XOR Value

med
30 min
Try to solve the Count Paths With the Given XOR Value problem.

Statement

You are given an m $ imes$ n integer matrix grid and an integer k.

You start at the top left cell (0,0)(0, 0) and want to reach the bottom right cell (m −1- 1, n −1- 1). From any cell, you can only move either down or right.

The XOR value of a path is the bitwise XOR sum of all elements along that path.

Return the total number of paths from (0,0)(0, 0) to (m −1- 1, n −1- 1) whose XOR value equals k. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq m ==== grid.length ≤300\leq 300

  • 1≤1 \leq n ==== grid[r].length ≤300\leq 300

  • 0≤0 \leq grid[r][c] <16< 16

  • 0≤0 \leq k <16< 16