Does anybody know better algorithm???
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???
Послано
SPIRiT 1 авг 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???
Послано
Tkach 2 авг 2006 01:08
Re: Does anybody know better algorithm???
Послано
SPIRiT 2 авг 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???
Послано
Tkach 2 авг 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???
I use dynamic programming.
Time is 0.125s
But memory...12***k
Re: Does anybody know better algorithm???
i cant understand - what kind of graph?
Does anybody know better algorithm???
Послано
Oybek 4 окт 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???
Послано
Rootis 13 окт 2007 00:33
what graph you build?