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

Does anybody know better algorithm???
Posted by Fokysnik 31 Jul 2006 14:52
I've written my program using recursion, and it gets Time Limit Exceded on test #5 :(
Any ideas wold be great.
Re: Does anybody know better algorithm???
Posted by SPIRiT 1 Aug 2006 14:01
I use KMP for substring search. And also instead of recursion for finding the shortest combination I use DP. And I get not TLE but WA:(. Must be some technical reasons. But the idea itself is great.
Re: Does anybody know better algorithm???
Posted by Tkach 2 Aug 2006 01:08
Build graph and use BFS...
It works fast just see http://acm.timus.ru/status.aspx?space=1&num=1002&author=35175

Edited by author 02.08.2006 01:10
Re: Does anybody know better algorithm???
Posted by SPIRiT 2 Aug 2006 19:23
And my solution worked too. DP is also suitable for the solution. What I didn't expected is that there is not always (-1) in the end of the input(!!!)
Re: Does anybody know better algorithm???
Posted by Tkach 2 Aug 2006 20:27
No.. I think all right...

My algo:
Cin >> S;
While (S!="-1")
 {
  Read_Words();
  Build_Graph();
  BFS();
  Write_Ans();
  Cin >> S;
 }
Re: Does anybody know better algorithm???
Posted by wangyin 11 Aug 2006 14:28
I use dynamic programming.
Time is 0.125s
But memory...12***k
Re: Does anybody know better algorithm???
Posted by ITStepDnepr 11 Dec 2006 21:05
i cant understand - what kind of graph?
Does anybody know better algorithm???
Posted by Oybek 4 Oct 2007 17:39
Edited by author 04.10.2007 17:42
sdfgdf
Edited by author 04.10.2007 17:42

Edited by author 04.10.2007 17:43
Re: Does anybody know better algorithm???
Posted by Rootis 13 Oct 2007 00:33
what graph you build?