thanx !! for pointing that out…
Yes, I’ve got what you’re trying to say. But I have not called the update function if both the no’s in the interval are same. So it perfectly runs fine for the case you’ve specified. There is something else which is probably going wrong. Are you able to pinpoint what’s missing?
Thats the only bug. Fixed! Thanks!
yjanin35: it is giving me Impossible, which is correct, it can be done with this approach
Okay, I got it. For example if I query an interval which has the value 0 but if I break the current interval and all the constituent intervals have value 1 then the answer should be “Possible” while my code gives “Impossible”.
no …it should be “possible”
I thought of the same thing. It can’t work as segment tree doesn’t store all the possible intervals explicitly but rather as sum of intervals, which creates the problem here. [1,2] and [3,4] being “connected” separately doesn’t mean that [1,4] is “connected” necessarily.
Exactly. It can’t be solved using segment trees. You got my point.
I try to solve this problem by using segment tree
http://www.codechef.com/viewsolution/4620492
Can anyone give me some test case please…
I also try to slove this one by segment tree . But getting WA ![]()
http://www.codechef.com/viewsolution/4620492
Any test case please ?
I don’t think the problem is solvable using seg trees. On the basis of above observations, you can create many test cases where the approach would fail.
rachilies: how can it be possible, could you show it step by step. n is 4 3 2 1 so when shuffling 1 2, it can be 3 4 2 1, so after this even if we shuffle 2 3 or 3 4 it ain’t gonna do any good to 3 which is in first position, so it should generate impossible
Sorry, i missed that part of can use the pair more than once, yeah it should be possible, and we are suppose to get the permutation given by user from initial permutation (1,2,3…N) using those pairs.
I was trying to solve by shuffling the input permutation to get the initial permutation (1,2,3…N).
how for n=7 and m=1 where ar[]={4,5,6,7,1,2,3} and for m=1(l=1 and r=7) is giving answer possible as through it we can just shuffle a[0] and a[6].
The code didn’t render correctly, here it is:
added an answer explaining it (the way I understand, at least :P).
hope it helps: ( PERMSUFF - Editorial - #17 by alvarobsp - general - CodeChef Discuss )