ENG
RUS
Timus 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
1143
. Electric Path
Algorithm
How to slove it with DP? O(n^3)??
[3] // Problem
1143. Electric Path
4 Apr 2004 12:45
md
Re: How to slove it with DP? O(n^3)??
[2] // Problem
1143. Electric Path
5 Apr 2004 00:42
It can be solved in O(n^2) time.
Fate
Re: How to slove it with DP? O(n^3)??
[1] // Problem
1143. Electric Path
5 Apr 2004 10:20
How?? Give me some hints?
Fate
Re: How to slove it with DP? O(n^3)??
// Problem
1143. Electric Path
5 Apr 2004 10:58
Is it right??
for s:=n downto 1 do
begin
d[s,1,1]:=0;
d[s,1,0]:=0;
for L:=2 to n+1-s do
begin
d[s,L,0]:=min(dis(s,s+1)+d[s+1,L-1,0],dis(s,s+L-1)+d[s+1,L-1,1]);
d[s,L,1]:=min(dis(s+L-1,s+L-2)+d[s,L-1,1],dis(s+L-1,s)+d[s,L-1,0]);
end;
end;
end;
© 2000–2026
Timus Online Judge Team
. All rights reserved.