Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:跪求 大神贴上Pscal版的代码。。。!!!!

Posted by Joker765 at 2015-07-25 10:39:54 on Problem 1062
In Reply To:跪求 大神贴上Pscal版的代码。。。!!!! Posted by:931169987 at 2015-07-24 19:44:49
type
  line=record
  y,last,cost,level:longint;
  end;
var
  f:array[0..500] of line;
  g:array[0..100,0..100] of longint;
  used:array[0..100] of boolean;
  n,m,i,en,j,a,b:longint;

procedure dfs(k:longint);
var i:longint;
begin
  for i:=1 to n do
    if (not used[i])and(g[k,i]>0) then
      begin
        used[i]:=true;
        dfs(i);
        if f[i].cost+g[k,i]<f[k].cost then f[k].cost:=f[i].cost+g[k,i];
        used[i]:=false;
      end;
end;


begin
  readln(m,n);
  fillchar(used,sizeof(used),false);
  for i:=1 to n do
    begin
      readln(f[i].cost,f[i].level,en);
      for j:=1 to en do
        begin
          readln(a,b); g[i,a]:=b;
        end;
      if abs(f[i].level-f[1].level)>m then
        for j:=1 to n do g[j,i]:=-1;
    end;
  dfs(1);
  writeln(f[1].cost);
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator