code : https://ideone.com/Kl9S4w
approach : in the men and women array i store the position of the desired women(i.e. for that men what is the position(priority) of xth women) and then store all the possible pairs and then try to sort that pairs using the information from the table. I have sorted on the basis of priority of marriage for the selected two person and then just select greedily.
please tell me where i am thinking wrong!
please tell the correct approach!