#C10174. Unique Paths in a Matrix

    ID: 39350 Type: Default 1000ms 256MiB

Unique Paths in a Matrix

Unique Paths in a Matrix

Given an \(m \times n\) matrix, your task is to print all unique paths from the top-left corner \((0,0)\) to the bottom-right corner \((m-1, n-1)\). At each step, you can only move either right or down. Each path should be printed as a sequence of coordinates separated by -> .

For example, for a 2x2 matrix the valid paths are:

  • (0,0) -> (0,1) -> (1,1)
  • (0,0) -> (1,0) -> (1,1)

And for a 3x3 matrix, there are 6 possible paths.

inputFormat

The input consists of a single line containing two integers \(m\) and \(n\) separated by a space, where \(m\) is the number of rows and \(n\) is the number of columns.

outputFormat

Output all unique paths from the top-left corner to the bottom-right corner. Each path must be printed on a separate line. The coordinates in each path should be formatted as (row,column) and connected using -> .

## sample
2 2
(0,0) -> (0,1) -> (1,1)

(0,0) -> (1,0) -> (1,1)

</p>