Answer: $\large\frac{1}{2}$$\large\frac{m_1-m_2}{m_1+m_2}$$gt^2$

When the bodies are released, the heavier one moves downward and the lighter one moves upward.

Net force in the direction of motion of $m_1$ is $F_1 = m_1g - T$ which is equal to $m_1a$ as per Newton's second law.

$\Rightarrow m_1g - T = m_1 a \quad (i)$

Net force in the direction of motion of $m_2$ is $F_2 = T-m_2g $ which is equal to $m_2a$ as per Newton's second law.

$\Rightarrow T-m_2g = m_2a \quad (ii) $

Solving $(i)$ and $(ii)$ for acceleration, $a \rightarrow a = \large\frac{m_1-m_2}{m_1+m_2}$$g$

Now, from Kinematics we know that $a = \large\frac{2d}{t^2}$$ \rightarrow d = \large\frac{1}{2}$$ at^2$

$\Rightarrow$ distance $d = \large\frac{1}{2}$$\large\frac{m_1-m_2}{m_1+m_2}$$gt^2$