Polynomial time guarantees for the Burer-Monteiro method