A generalization of determinant formulae for the solutions of Painlevé II and XXXIV equations