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了,那位高手帮忙看一下(用递归搜的)#include <stdio.h> typedef struct { int rare; int level; int nextPoint[100][2]; }Point; Point point[100]; int level[2];//交易的人中等级最高的和最低的 int m,num; int input() { int i,j; scanf ("%d%d",&m,&num); for (i=0;i<num;++i) { scanf("%d%d%d",&point[i].rare,&point[i].level,&point[i].nextPoint[0][0]); for (j=1;j<=point[i].nextPoint[0][0];++j) scanf("%d%d",&point[i].nextPoint[j][0],&point[i].nextPoint[j][1]); } level[0]=level[1]=point[0].level; return 0; } int output(int n) { int i,temp,min=point[n].rare; if (point[n].nextPoint[0][0]==0) return point[n].rare; for (i=1;i<=point[n].nextPoint[0][0];++i) { temp=output(point[n].nextPoint[i][0]-1); temp+=point[n].nextPoint[i][1]; if ((temp<min) && ((point[n].level+m)>=level[1]) && ((point[n].level-m)<=level[0])) min=temp; if (point[n].level>level[1]) level[1]=point[n].level; if (point[n].level<level[0]) level[0]=point[n].level; } return min; } int main () { input(); printf ("%d",output(0)); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator