I think there are better solutions than O(n^2).
One easy thing is to go backwards through the sticks and do something like a sieve. If the actual stick is one of the top stick you try do find the cutting with all of the sticks thrown before.
This works in worstcase O(n*nr_of_topsticks)
Another ...
Search found 10 matches
- Thu Sep 22, 2005 9:54 pm
- Forum: Volume 109 (10900-10999)
- Topic: 10902 - Pick-up Sticks
- Replies: 24
- Views: 17879
- Wed Sep 21, 2005 11:17 pm
- Forum: Algorithms
- Topic: Geometry Problem...
- Replies: 7
- Views: 2488
- Wed Sep 21, 2005 11:24 am
- Forum: Algorithms
- Topic: Geometry Problem...
- Replies: 7
- Views: 2488
Yes, what Krzysztof said is right, you can always create it, if longest edge < sum of the other edges.
This was one of the problems of this years Baltic Olympiad of Informatics. One Solution to find such a polygon is to put all the points on a circle and do a binary search over the radius. You can ...
This was one of the problems of this years Baltic Olympiad of Informatics. One Solution to find such a polygon is to put all the points on a circle and do a binary search over the radius. You can ...
- Fri Sep 16, 2005 10:07 am
- Forum: Volume 100 (10000-10099)
- Topic: 10004 - Bicoloring
- Replies: 93
- Views: 45243
I think there are some things missing in your code.
First you just insert the edge from input [0] to input [1] and not the backedge. In the problemstatement its clearly said that we have nondirectional edges.
Another thing is that you go through the nodes by there number. You should do a DFS (or BFS ...
First you just insert the edge from input [0] to input [1] and not the backedge. In the problemstatement its clearly said that we have nondirectional edges.
Another thing is that you go through the nodes by there number. You should do a DFS (or BFS ...
- Thu Sep 08, 2005 10:44 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10061 - How many zero's and how many digits ?
- Replies: 43
- Views: 28821
- Mon Jun 13, 2005 11:36 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10062 - Tell me the frequencies!
- Replies: 235
- Views: 69473
- Mon Jun 13, 2005 7:41 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10093 - An Easy Problem!
- Replies: 52
- Views: 22918
I think that there is a problem with your q, because it can easily become very large and so wont fit in a long variabel. So you can after every loop take the mod of q so, instead of q*=base you can use
q := q*base mod (base -1) // i am a pascal programmer, so i think it must be (q*base)%(base-1) in ...
q := q*base mod (base -1) // i am a pascal programmer, so i think it must be (q*base)%(base-1) in ...
- Mon Jun 13, 2005 1:51 pm
- Forum: Volume 101 (10100-10199)
- Topic: 10107 - What is the Median?
- Replies: 74
- Views: 31439
- Fri Jun 10, 2005 6:45 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10054 - The Necklace
- Replies: 62
- Views: 42100
and that is right too, especially by better your runtime complexity you can even shorten your program. when you just test if all nodes have odd degree and after that do your solve procedure this is enough. you just have to check weather all edges have been used to create the circle. if not all edges ...
- Fri Jun 10, 2005 5:37 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10054 - The Necklace
- Replies: 62
- Views: 42100