You can find the solution of Problem A Div1 as soon as you search about it.
You can see this link
you've to add just one condition in ”else” and get problem accepted
if(i == pp.first || i == pp.second || j == pp.first || j == pp.second) continue;
Accepted Solution 109890606
Therefore, this is unfair to some of the contestants.
Is it possible to find a solution ???