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ā.
its giving me ACCESS DENIED when I click on setterās solution or testerās solution.
I tried to solve this using Union Find.
I am using Union find to find the range.
http://www.codechef.com/viewsolution/4618833
I donāt know where this code is failing.
Ahā¦nyc questionā¦missed the case of Completely overlapping cases during contest(eg. [1,4] and [2,3]) and got WAā¦Fixed Now . Thanks @Witua and @Kostya_by
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).
can anyone tell me what is wrong with my solution?thanx in advance.
link to my solution is http://www.codechef.com/viewsolution/4624448 any test case where my solution fails?
please explain the solution in a more elaborate way
i m still not able to understand.
If we sort the elements in query range for each query then in the last the array we should get is the permuted one if āpossibleā n āimpossibleā if not possible !!
pls help!!
http://www.codechef.com/viewsolution/4621752
i used the union find approach. And for every interval i merge from a+1 to b.
and finally check of parent of index and target permutation should be same.
Please help me where i am wrong.
And provide resources of scanline algo. this tutorial was not so helpful me. Donāt know why this time i can not understand the problem.