Codechef august challenge, Strings and Graphs segmentation fault!

Can anyone pls help me why am i getting NZEC in string and graphs question. Code is Here

//