Moving through matrix - MarisaOJ: Marisa Online Judge

Moving through matrix

Time limit: 1000 ms
Memory limit: 256 MB
You are given a matrix with n rows and m columns. Currently, you are at position (1,1), and your goal is to move to position (n,m). However, there are k obstacles, meaning you cannot move to the cells occupied by these obstacles. Count the number of ways to move from cell (1,1) to (n,m). Every move, you can choose to move from (i,j) to either (i+1,j) or (i,j+1). ### Input - The first line contains three integers n, m, and k. - The next k lines each contain two integers x and y, representing the position of an obstacle at row x, column y. ### Output - Output the number of ways to move, modulo 109+7. ### Constraints - 1≤n,m≤105. - 1≤k≤100. - 1≤x≤n. - 1≤y≤m. ### Example Input: 22112 Output: 1