cswork / OAOpen practice workspace

AmazonOA #84

Find Allocation Ways (Grid Expansion)

Estimated HardStatement and editorial — judging is being prepared

Topics (AI-labelled)Grid DPBits & Math

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 ≤ 1000
  • 1 ≤ q1 ≤ q2 ≤ 1000

Example

p1 = 1, q1 = 1, p2 = 2, q2 = 2
answer = 3

Editorial

Loading solution…