Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
超简单的算法,测试数据过了,可是就是wA(附codes)#include<iostream> using namespace std; int main() { int map[30][30],i,j,sum,n,num,min,k; char c[2],b[2]; while(1) { for(i=0;i<=27;i++) for(j=0;j<=27;j++) map[i][j]=200; cin>>n; if(n<=0) break; sum=0; for(i=0;i<n-1;i++) { cin>>c; cin>>num; for(j=0;j<num;j++) { cin>>b; cin>>min; map[c[0]-'A'][b[0]-'A']=map[b[0]-'A'][c[0]-'A']=min; } } for(i=0;i<n-1;i++) { min=200; for(j=0;j<n;j++) { if(map[i][j]<min) { min=map[i][j]; k=j; } } map[k][i]=200; if(min<200) sum+=min; } cout<<sum<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator