|
|
back to boardShow all messages Hide all messagesBellman-Ford. Do Bellman-Ford once to find the longest path. If there is a positive cycle then Yes,otherwise No. I am in contest know please help I must solve this problem 1217. N = 12, 14, 16. 12--3052783504 14--266095289560 16--23194144960900 GL! [code deleted] Edited by moderator 23.06.2006 17:15 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. [code deleted] Edited by moderator 23.06.2006 17:15 another question : "pre[b]:=pre[a]+pre[b]+[a];" May I use "pre[b]:=pre[a]+[a]" ?? |
|
|