Uva 13094
How should I approach the problem 13049 ? I tried a simple approach (for lopps,etc) but it timed out as expected. Please provide a detailed(:P) explanation. P.S Anything about SQRT Decomposition?
EDIT: It already ended, lol.
Well, I solved this problem using implicit treap. You can read this nice treap tutorial (Google translate).
My solution is a little slow, though. I want to know an alternative solution too :P
EDIT: It already ended, lol.
Well, I solved this problem using implicit treap. You can read this nice treap tutorial (Google translate).
My solution is a little slow, though. I want to know an alternative solution too :P