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 1002. Phone Numbers

Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Posted by Hikmat Ahmedov 22 Aug 2012 22:02
Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Please don't say just DP+tree.
How do you buld a tree ?
Building a tree is not problem, we can build the tree using STACK but it gives TLE on test 5.
It takes too much time to build the whole tree.
In this promlem, order of the words is important, so I have no idea how to use DP.

Please, give some hints.
Thanks,
Re: Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Posted by KNIGHT0X300 26 Aug 2012 22:47
just DP Similar to Knapsack(I think) and need to store the previous element to recover the path in the end :)
Re: Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Posted by Hikmat Ahmedov 31 Aug 2012 10:46
In Knapsack order is not important, but in this problem order is important.
How do you deal with order ?
Re: Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Posted by Endoveg 30 Jul 2013 00:57
KNIGHT0X300 is right. It is an example of DP problem.
Re: Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Posted by Mohammad Samiul Islam 19 Mar 2014 20:11
I got AC using Trie Tree and Knapsack DP.
Re: Greedy algorithm doesn't pass Test 3. Which algorithm to use ?
Posted by dangminhhieu78 2 Jan 2015 08:37
use hash+dp