Of course the problem may be solved within Newtonian mechanics quite trivially, by realizing that the only way the segment can remain (a) horizontal and (b) of fixed length is if the initial conditions are yA(0)=yB(0), vA,x(0)=vB,x(0) and vA,y(0)=vB,y(0).
Therefore it doesn't make sense demanding that the segment can satisfy conditions (a) and (b) if the initial conditions are different. It suffices to write Newton's equations along x and y for the two particles to show this.
Then Newton's equations ensure that yA(t)=yB(t) and that |xA(t)-xB(t)|=|xA(0)-xB(0)| which every first year student learns in the first few weeks.
Newton's equations, also, imply that a Galilean transformation along x is consistent with these relations, since the force along x is zero...
And the statement that the vertical distance could change is, just, wrong. There's just no way it could change; it can be shown to be a constant of motion, by writing the equation satisfied by the relative distance, yA(t)-yB(t), namely d2(yA(t)-yB(t))/dt2=0, since the acceleration is constant along y and the same for both particles-and both particles are assumed to have the same initial velocity along y.
In fact it's, also, trivial to see from Newton's equations, that, if the two particles are subject to the same force along x, the segment will remain horizontal and of fixed length; it will just be accelerating along x. Motion along x is independent of motion along y...
The equation for yA(t)-yB(t) isn't invariant under transformations to a non-inertial frame; in Newtonian mechanics these would be transformations of time that aren't linear functions of time. But that's no surprise. (And Lorentz transformations are transformations that are linear in the coordinates.)