Comments
+23

Funny that one of these bots was hacked: http://codeforces.me/contest/796/submission/26272062

Here's an idea: Use your BFS on a starting node. Keep track of every node you could reach on this running of the BFS (use a vector, for example). Now, for each of these nodes, you just need to check if their degree is the size of this vector -1. Do this for every non-visited node. While this condition is true, answer is YES. Otherwise, NO.

I believe it's because the function pow will work differently depending on the compiler, since it's not supposed to work with large numbers like 10^18. Your code passes replacing it with powl. Check: http://en.cppreference.com/w/c/numeric/math/pow