Special Paths
Practice
4.2 (679 votes)
Problem
68% Success 2004 Attempts 3s Time Limit 256MB Memory 1024 KB Max Code

You are given a rectangular grid with n rows and m columns. The rows are numbered 1 to n, from bottom to top, and the columns are numbered 1 to m, from left to right.

You are also given k special fields in the form (row, column). For each i, where 0 <= i <= k, count the number of different paths from (1, 1) to (n, m) that contains exactly n special fields.

There is one rule you must follow. You are only allowed to make moves that are straight up or to the right. In other words, from each field (row, column), you can only move to field (row+1, column) or field (row, column+1).

Output an array of k + 1 elements. The i-th element (0-indexed) must be the number of different paths that contain exactly i special fields. Since, the answer can be too big, output it modulo 1000007.

Input:
First line contains three space separated integers, n, m and k. Next k lines, each contain two space separated integers, the coordinates of a special field.

Output:
k + 1 space separated integers, the answer to the question.

Constraints:
1 <= n, m, k <= 100
For all coordinates (r, c) - 1 <= r <= n, 1 <= c <= m
All coordinates are valid and different.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
83 votes
Tags:
Ad-HocApprovedData StructuresEasyImplementationOpen
Points:30
Tags:
MathematicsSieveEasy-MediumNumber TheoryFactorization
Points:50
1 votes
Tags:
MathematicsSieveHardNumber TheoryFactorization
Editorial

No editorial available for this problem.