Solve without Segment Tree
Is this problem solvable in any other way not using Segment Tree?
Can this problem solved using Fenwick Tree?
Re: Solve without Segment Tree
gcd ~ min
but, we can't use fenwick tree, because, when update, new minimum should be no more than previous.
but I could be wrong :)
Re: Solve without Segment Tree
Posted by
Kleninz 19 Sep 2011 09:52
I used gcd tree and set. And I got TL 17. Then I remade my recursive update function to nonrecursive. I got AC. Then I remade my recursive get_gcd function to nonrecursive function. AND GOT TL AGAIN!
Treap
Using a treap is another nice way.
AC 0.296 without any optimizations (and 0.234 after some :) )
Edited by author 20.09.2011 21:38
Re: Solve without Segment Tree
I use SQRT-decomposition. Accept 0.468 on Java.
Re: Solve without Segment Tree
I also solved it by Sqrt-decomposition. Accept 0.292 on C++
Augmented BST
I used balanced bst (AVL tree), keeping GCD for each subtree. Got 0.39
Thought about segment tree but found it not so elegant. How does your segment tree solution look?
ibra, Pavel Kovalenko, thanks for sqrt-decomposition hint!
Edited by author 01.10.2011 21:08
Re: Augmented BST
Posted by
vlyubin 10 Feb 2012 07:36
Did you use some modifications to Sqrt-decomposition? I seem to be unable to AC it. I use C++ (on Java it's a bit tougher) and I use multiset for storing integer, not a vector. I get TLE 22 ... I tried to modify sizes, but that doesn't seem to help.Did you use Sqrt-decomp twice?
Re: Solve without Segment Tree
Posted by
ucs6 23 Apr 2012 23:11
Could you explain a little more about "SQRT-decomposition" or where I can find an introduction to it?
I tried google it but it's nowhere.
Thanks!
What is SQRT-decomposition?
Posted by
ucs6 24 Apr 2012 10:42
Could you explain a little more about "SQRT-decomposition" or where I can find an introduction to it?
I tried google it but it's nowhere.
Thanks!
Re: Treap
Posted by
Jumbo 18 Jul 2012 17:55
Re: What is SQRT-decomposition?
Posted by
Jumbo 19 Jul 2012 15:35