An exact algorithm for time-dependent variational inference for the dynamic stochastic block model