#C3974. Counting Grid Paths

    ID: 47460 Type: Default 1000ms 256MiB

Counting Grid Paths

Counting Grid Paths

You are given a grid of size \(m \times n\) and two cells specified by their 1-indexed coordinates: the starting cell \((x_s, y_s)\) and the target cell \((x_t, y_t)\). Your task is to compute the number of distinct paths from the starting cell to the target cell if you can only move right or down.

Note:

  • If either the starting cell or the target cell is out of the grid bounds, the answer is \(0\).
  • If \(x_t < x_s\) or \(y_t

    inputFormat

    The input consists of a single line containing six space-separated integers: \(m\), \(n\), \(x_s\), \(y_s\), \(x_t\), and \(y_t\).

    outputFormat

    Output a single integer representing the number of distinct paths from \((x_s, y_s)\) to \((x_t, y_t)\) using only right and down moves.

    ## sample
    3 3 1 1 3 3
    
    6
    

    </p>