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<iostream> #include<string.h> #include<math.h> using namespace std; struct person { int pri; int pos; } node[110]; int road[110][110]; int mark[110], ans[110]; int t,n,maxpos,minpos; void find(int k) { int i; if(ans[k] != -1) return; else { ans[k] = node[k].pri; for(i=1; i<110; i++) { if(road[k][i] != -1 ) { if(minpos > node[i].pos) minpos = node[i].pos; if(maxpos < node[i].pos) maxpos = node[i].pos; if( maxpos - minpos <= t ) { if(ans[i] == -1) find(i); if(ans[i] + road[k][i] < ans[k]) ans[k] = ans[i] + road[k][i]; } maxpos = node[k].pos; minpos = node[k].pos; } } } return ; } int main() { int i,j,m,a,p; for(i=0; i<110; i++) for(j=0; j<110; j++) road[i][j] = -1; for(i=1; i<110; i++) ans[i] = -1; cin>>t>>n; for(i=1; i<=n; i++) { cin>>node[i].pri>>node[i].pos>>m; for(j=0; j<m; j++) { cin>>a>>p; road[i][a] = p; } } maxpos = node[1].pos; minpos = node[1].pos; find(1); cout<<ans[1]<<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