ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1846. GCD 2010

Solve without Segment Tree
Posted by havaliza 18 Sep 2011 22:58
Is this problem solvable in any other way not using Segment Tree?
Can this problem solved using Fenwick Tree?
Re: Solve without Segment Tree
Posted by Vit Demidenko 19 Sep 2011 08:44
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
Posted by Borozdin Kirill 19 Sep 2011 20:26
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
Posted by Pavel Kovalenko 20 Sep 2011 20:38
I use SQRT-decomposition. Accept 0.468 on Java.
Re: Solve without Segment Tree
Posted by ibra (TNU) 20 Sep 2011 21:21
I also solved it by Sqrt-decomposition. Accept 0.292 on C++
Augmented BST
Posted by luckysundog 1 Oct 2011 21:07
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
I got TL with treap ><, it's strange.
Can someone help me?
Code here: http://www.everfall.com/paste/id.php?bkqpp0lvnsye

Edited by author 18.07.2012 17:56

Edited by author 18.07.2012 17:56