PROBLEM IN CODING THIS

i tried coding this using sets instead of vectors so that i could get nodes from the user. and i am having problems in coding it. Can you help me with it