As preamble, I note that the equation for this shear stress / force / flow is something that seems to suffer from almost everyone adopting a different nomenclature. I learnt it as longitudinal shear = Q A y[bar] / I. In that form, the longitudinal shear is a force per unit length along the section, and Q is the shear force in the section.
However, I will adopt the nomenclature that the question is adopting. In this answer, I'm adopting:
S = longitudinal shear force per unit length across a defined boundary of interest, that boundary being perpendicular to a plane section. This boundary is normally a single plane on which you could slice off a part of the section, but it doesn't have to be.
V = vertical shear force in the plane section.
A = an area (see below).
y = a distance (see below).
I = second moment of area of the whole plane section.
The equation in question is then S = V A y / I.
(The question has an intermediate value Q = A y, but I'm going to ignore that - you can substitute it back in if you like, having calculated A and y, at any point in this discussion.)
The value of A is the area of a 'chunk' of the section. The value of y is the distance from the neutral axis of the whole section to the centroid of the sliced off part. It doesn't actually matter if the chunk is the result of a single planar slice, or an arbitrary portion of the section.
In case b there's a chunk that's the top plank. It's a rectangle d wide and b high. The centroid of that part is exactly central, b/2 from the top and bottom faces of that plank. The y value will be the distance from the centre of that plank to the neutral axis of the whole section.
For sake of discussion, suppose the neutral axis of the whole section is 0.75xc from the bottom edge. Suppose also that a=d+2xb and e=b+c (ie, as it appears to be drawn).
In case a):
A = a * b
y = 0.25 * c + 0.5 * b
in case b):
A = b * d
y = exactly the same as case a), because the centroid of area A in case a) is at the same place as the centroid of area A in case b)
The second half of the question contains an error about what y is. The value y in the equation is not the distance from the centroid of the whole section to the cut plane. That is, y is not what is labelled as y in the diagram, it should be the distance from the whole section neutral axis at NA to the centroid of the hatched area.
It's worth noting that the S = V A y / I equation is only valid in the case of a prismatic section where the chunk is arranged such that A y and I do not vary along the length of the member. Some thinking about the derivation of the equation is relevant (and explains the assertions made above):
The axial bending fibre stress at any point on a section is calculated from stress = M y / I, where M is bending moment, y is now the distance from the neutral axis to the point where the stress is calculated and I is the second moment of area of the whole section.
If you consider any arbitrary chunk of the cross section, the axial force (F) on that whole chunk is the integration across the area of the chunk of (M y / I). That is, F = M A y / I, if A is the area of the chunk and y is back to being the distance from neutral axis of the whole section to centroid of the chunk.
Now, consider repeating that an increment along the member. There's now a different axial force on the chunk, and the way that force got there was by longitudinal shear across the perimeter of the chunk. Or, to put it another way, if x is position along the beam, the longitudinal shear flow across the chunk boundary = dF/dx = d(M A y / I)/dx. However in that differentiation, A y and I are all constant with varying x, so dF/dx = dM/dx A y / I. However, we know dM/dx (rate of change of bending moment along the beam) as something else - it's the vertical shear force in the section: dM/dx = V.
Hence longitudinal shear across the chunk boundary S = dF/dx = V A y / I
The important thing to note is that this derivation depends absolutely upon A y and I not varying with x - if they do vary, you can't simply recalculate S = V A y / I with different A values along the section, because with an A that varies with x (for example), d(M A y / I)/dx does NOT equal dM/dx A y / I. In that case you need to apply the differentiation product rule, so d(M A y / I)/dx = (dM/dx A + M dA/dx) y / I. Actually, of course, if A is varying with x it's almost certain that y and I are likewise varying with x, and you'll need to multiply out all four terms as varying-with-x.