spoj pt07y bfs solution

this is my code i have seen various solution in which they have inserted adj[x].push_back(y);
in this way only but it is given that it is undirected so we sholud insert in both ways please tell me what is wrong with my code