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

帮忙看看我的程序为什么wa

Posted by JerryTang at 2011-03-17 21:28:38 on Problem 1502
#include<iostream>
#include <stdlib.h>
using namespace std;
long maxmax=100000000;
int main()
{
    long n,i,j,k,a[128][128],d[1000],max=0,find[1000];
    char x[100];
    cin>>n;
    for(i=1;i<=n;i++)
      {
         d[i]=maxmax;
         find[1000]=0;
         for(j=1;j<=n;j++)
         {
            if(i==j)a[i][j]=-1;
            else a[i][j]=0;
         }
      }
    for(i=2;i<=n;i++)
      for(j=1;j<i;j++)
      {
         cin>>x;
         if(x[0]=='x'){a[j][i]=-1;a[i][j]=-1;}
         else{a[i][j]=atoi(x);a[j][i]=a[i][j];}
      }
    /*for(i=1;i<=n;i++)
      {for(j=1;j<=n;j++)cout<<a[i][j]<<" ";cout<<endl;}*/
    for(i=1;i<=n;i++)d[i]=a[1][i];
    for(i=1;i<=n;i++)
    {
       long minn,nn;
       minn=maxmax;
       for(j=2;j<=n;j++)
       {
          if(d[j]<minn&&find[j]>=0&&d[j]>0){minn=d[j];nn=j;}
       }
       find[nn]=-1;
       for(j=1;j<=n;j++)
       {
          if(d[nn]+a[nn][j]<d[j]&&d[nn]>=0&&a[nn][j]>=0){d[j]=d[nn]+a[nn][j];}
       }
    }
    long minn;
    minn=0;
    for(i=1;i<=n;i++)
      {for(j=1;j<=n;j++)cout<<a[i][j]<<" ";cout<<endl;}
    for(i=2;i<=n;i++){cout<<d[i]<<endl;if(d[i]>minn&&d[i]>=0)minn=d[i];}
    cout<<minn;
    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