Any hint? How to solve it with shortest path?
Re: Any hint? How to solve it with shortest path?
Bellman-Ford.
Do Bellman-Ford once to find the longest path.
If there is a positive cycle then Yes,otherwise No.
Please in 1217 help I need answer N=12, 14, 16. help I am in contest
Послано
BSP 24 окт 2004 19:33
I am in contest know please help I must solve this problem
1217. N = 12, 14, 16.
Re: Please in 1217 help I need answer N=12, 14, 16. help I am in contest
12--3052783504
14--266095289560
16--23194144960900
GL!
What's the length of edges?
I get WA #13, could you help me?
[code deleted]
Edited by moderator 23.06.2006 17:15
Here's what's wrong in your algorithm (+)
this is wrong:
...
else begin
writeln('YES');
halt;
end;
It isn't necessarily a YES. You can't be sure that there's positive cycle by only condition that you've found 2 different positive values for money[b]. Your code can be easily modified (took me 1 min) though in such a way that you get AC, checking the condition of 'YES' answer correctly. I can write you an email, telling how to do that, if you want.
I've written a new prog, but it's WA 19. Can you help?
[code deleted]
Edited by moderator 23.06.2006 17:15
Ah, it's really easy to get AC. It's YES only if i=n.
Excuse me, why it's YES only if i=n ???
another question :
"pre[b]:=pre[a]+pre[b]+[a];"
May I use "pre[b]:=pre[a]+[a]" ??