Polycondensates having nitrogen-containing heterocyclic rings in the main chain