I don't understand the editorial solution


#1

I get it that when p==0 it means that its a multiplication of N and therefor we end. but i don’t understand why it cannot overlap with 2 solution when we just use %N ?i’m missing somthing


#2

If two nodes have the same value we take the smaller one. Which is why we ignore it if it has been visited.