Reconstruct a zigzagified matrix

Jelly, 18 13 bytes

pS€żị"¥pỤỤị⁵s

Takes number of rows, number of columns and a flat list as separate command-line arguments.

My code is almost identical to the one in the twin challenge. The only differences are an additional (which inverts the permutation of the indices) and an s (to split the output into a 2D array).

Try it online!


MATL, 29 bytes

:!i:+-1y^8MtsQ/*-X:4#S2$S1GZC

Input is height, width, vector separated by newlines.

This reuses part of the code in my answer to the related challenge.

Try it online!

Explanation

:!      % take number of rows, r, as input. Generate column vector [1;2;...;r]
i:      % take number of columns, c, as input. Generate row vector [1,2,...,c] 
+       % add with broadcast. Gives 2D array
-1      % push -1
y^      % duplicate previous 2D array. Compute -1 raised to that
8M      % push [1;2;...;r] again
tsQ/    % divide by its sum plus 1
*       % multiply
-       % subtract
X:      % linearize 2D array into column array
4#S     % sort and push the indices of the sorting. Gives a column vector
2$S     % take vector as input. Sort it according to previous column vector
1G      % push r
ZC      % reshape into columns of r elements