Continuous-time quantum Monte Carlo solver for dynamical mean field theory in the compact Legendre representation