Time-dependent evolution of cosmic-ray-mediated shocks in the two-fluid model