Holiday Accomodation SPOJ

I am getting Segmentation fault on running my code on the addEdge() method when inserting edges, I am not able to figure out why it’s happening please help

Link of code: https://ideone.com/XxTpjf

the nodes are from 1 to n
not from 0 to n-1
so size of array should be n+1
either pass n+1 here 1. Graph g(n);
or use V+1 here l = new list<pair<int, int>>[V+1];