oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

anothersquare Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

statement.txt

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

Math

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
113101s32MBMinimum
217201s32MBMinimum
322301s32MBMinimum
414401s32MBMinimum
534501s32MBMinimum
6011s32MBMinimum

Judge Compile Command

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

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.