Doof on Cartesian

I had this solution https://www.codechef.com/viewsolution/35691537 which resulted in WA but then I just changed my vector to array https://www.codechef.com/viewsolution/35691665 and it worked what’s the reason behind this!!
Please explain.

Try printing the n’th item in an array of n size or vector of n size , it gives random output, that random may have matched with b variable of yours giving output -1 instead of n

Congo, your vector solution got accepted
https://www.codechef.com/viewsolution/35692458

Just edited this portion

    if(l1!=n && v[l1]==b)
    {
          cout<<-1<<endl;
    }

There is already a discussion going on this topic

1 Like