@pushkarmishra probably because the author’s solution seems to be using a different input/output than the final problem? This is probably due to a revision of the problem. I think the int aa overflowed to a negative hence aa<2. Try another accepted solution? (like AnonymousBunny)
Thank you
The first part of the solution is really nice. I think you can leave out the random part by choosing the sets appropriately. log(k)+1 should be enough by e.g using the ith special point for the starting set in round j if the jth digit in the binary representation of i is one.
@ceilks Yeah, that’s true, good point! I’m not sure why I defaulted to random, but I guess it’s kind of nice since you could see it as log(# of tests) with the full feedback.
That is because handling of 64 bit integers is slower than 32 bit integers. Thus, you should avoid long long whenever you don’t really need it.
because using long long increases time consumption so i think your solution got tle
Nice one man
Nice one!!!
Alternative solution: optimised version of subtask 2
while (!pq.empty() && pq.top().ff < ans)
Here, we break when we’ve exceeded the current best distance
if (node.second != source && node.isSpecial()) ans = min(ans,node.first);
And here we minimise the distance the first time we hit a special node (and then break)