Polycondensates having nitrogen-containing heterocyclic rings in the main chain of the macromolecule