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

就是找不出错了 哪位大牛帮我看看

Posted by Moon_1st at 2010-01-27 21:02:25 on Problem 1062
试了几组测试数据 都没错 但还是WA 哪位大牛能帮忙看看 不胜感激啊
#include <iostream>
#include <memory.h>
#define maxn 1000000000;
using namespace std;
typedef struct
{
  long p,l,x;
  long t[101],v[101];        
}V;
long n,m,ans,dist[101];
V map[101];
bool finish[101];
void init()
{
  int i,j;
  cin>>m>>n;
  for(i=1;i<=n;i++)
  {
    cin>>map[i].p>>map[i].l>>map[i].x;
    for(j=1;j<=map[i].x;j++)
      cin>>map[i].t[j]>>map[i].v[j];                        
  }     
  ans=maxn;
}
void dijkstra()
{
  long i,j,k,min,d,r;
  for(r=1;r<=n;r++)
  if(map[r].l-map[1].l>=0&&map[r].l-map[1].l<=m)
  {
  memset(finish,false,sizeof(finish));
  for(i=1;i<=n;i++)
    dist[i]=maxn;
  dist[1]=map[1].p;
  finish[1]=true;
  for(i=1;i<=map[1].x;i++)
    if(map[r].l-map[map[1].t[i]].l<=m&&map[r].l-map[map[1].t[i]].l>=0)
      dist[map[1].t[i]]=dist[1]-map[1].p+map[1].v[i]+map[map[1].t[i]].p;
  for(k=1;k<n;k++)
  {
    j=1;
    min=maxn;
    for(i=1;i<=n;i++)
      if(!finish[i]&&dist[i]<min)
      {
        min=dist[i];
        j=i;
      }
    finish[j]=true;
    for(i=1;i<=map[j].x;i++)
      if(map[r].l-map[map[j].t[i]].l<=m&&(!finish[map[j].t[i]])&&map[r].l-map[map[j].t[i]].l>=0)
      {
        d=dist[j]-map[j].p+map[j].v[i]+map[map[j].t[i]].p;
        if(dist[map[j].t[i]]>d)
          dist[map[j].t[i]]=d;                                            
      }                  
  }     
  for(i=1;i<=n;i++)
    if(ans>dist[i])
      ans=dist[i];
  }
}
void print()
{
  cout<<ans<<endl;     
}
int main()
{
  init();
  dijkstra();
  print();
  return 0;  
}


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