I am trying to submit almost identical code(Beautiful Graphs from codeforces discussed in Graph-10 Competitive Problems), but getting Wrong Answer. The question has been solved in C++ in the video but I solve the problems in Java and I am unable to understand what changes should be made if it is because of language.
My code is pasted here: https://pastebin.com/Jp7FUbie
Please have a look because I am unable to solve problems even after understanding the concepts and code.