← All problemsSign in

Huge Grid (Hard Version)

CodeChefRating 2518Open on judge ↗

**This is the hard version of the problem. Here your task is to count the number of different paths that achieve the minimum possible path sum.** Given a binary sequence $A$ of length $N$, we construct an $N \times N$ matrix $B$ as follows: - If $i \leq j$, then $B_{i,j} = \sum_{k=i}^j A_k$. - Otherwise, $B_{i,j} = B_{j,i}$. Define a path from $(1,1)$ to $(N, N)$ as a sequence of pairs: $$ P =

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start