Correct.

y = speed 1st train, x = speed 2nd train, a = time paths crossed

When paths crossed:

1st train travelled ay, 2nd train travelled ax

After paths crossed:

1st train travelled y, 2nd train travelled 4x

So ay = 4x ; a = 4x / y

And ax = y ; a = y / x

4x / y = y / x

y^2 = 4x^2

y = 2x