Sign in

Build a 3D DP Table

intro

Three-dimensional DP tables (dp[day][item][capacity] and the like) start the same way as their 2D cousins. Implement make_dp3(n, m, k, fill) returning an n x m x k table: n outer planes, each holding m rows of k columns, every cell equal to fill. Watch the dimension order: dp[i][j][l] must be valid for 0 <= i < n, 0 <= j < m, 0 <= l < k.

Example: make_dp3(1, 2, 3, 7) returns one plane containing 2 rows of 3 sevens each: {{{7,7,7},{7,7,7}}}.

Input format: each test in tests/*.in is laid out as:

  • Line 1: n m k f, the four arguments to make_dp3(n, m, k, f): the three dimension sizes and the fill value.

Test 02.in reads:

4 2 3 -1

This is a 4 x 2 x 3 block filled with -1.

Where you'll use it:

✦ Solution & editorial unlock with the pass.

Loading...