AmazonOA #84
Find Allocation Ways (Grid Expansion)
估计困难评测数据准备中,可先阅读题面
Grid expansion: start (p1, q1), end (p2, q2). Each step: add a row (vertical, top) or add a column (horizontal, right). Each added "frontier" gets exactly one filled cell. Count distinct final fillings, mod 998244353.
Constraints
1 ≤ p1 ≤ p2 ≤ 10001 ≤ q1 ≤ q2 ≤ 1000
Example
p1 = 1, q1 = 1, p2 = 2, q2 = 2
answer = 3