#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

Problem Name: grid Problem Description: Josh is bad at counting, and today he needs you to help him count! He sits at the left of the grid, and he wants to know how many ways he can get from the left to a range of squares on the grid! He can choose to start from any square on the leftmost column, and he must reach (X,i), where i <= Y. However, Josh can only choose to move down or right. He cannot move left or up, so any path he chooses to follow will not be a cycle. Input Format: The first line contains 3 integers, H, W and Q, representing the height of the array, the width of the array and the number of queries. The next Q lines will contain 2 integers each, X and Y, representing a square in the array. It is guaranteed that X < H and Y < W. Output Format: Q lines of 1 integer each, representing the sum of the number of ways Josh can reach (X,0) ..... (X,Y) from (0,0) ... (0,H-1) mod 1000000007. Sample Input: 5 5 3 0 4 2 2 4 4 Sample Output: 15 15 210 Limits: Subtask 1 (0%): Sample Subtask 2 (13%): 0 < H <= 100, 0 < W <= 100, 0 < Q <= 100 Subtask 3 (17%): 0 < H <= 1000, 0 < W <= 1000, 0 < Q <= 1000 Subtask 4 (22%): 0 < H < = 10000, 0 < W <= 10000, 0 < Q <= 10000 Subtask 5 (14%): 0 < H < = 100000, 0 < W <= 100000, 0 < Q <= 100000 Subtask 6 (34%): 0 < H < = 1000000, 0 < W <= 1000000, 0 < Q <= 1000000

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 13 | 10 | 1s | 32MB | Minimum |

2 | 17 | 20 | 1s | 32MB | Minimum |

3 | 22 | 30 | 1s | 32MB | Minimum |

4 | 14 | 40 | 1s | 32MB | Minimum |

5 | 34 | 50 | 1s | 32MB | Minimum |

6 | 0 | 1 | 1s | 32MB | Minimum |

### Judge Compile Command

g++-8 ans.cpp -o anothersquare -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512