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 |
Please help, why I got run time error?#include <iostream> #include <stdio.h> #include <algorithm> using namespace std; int t[501]; struct E{ int p; int n; int w; }e[2510]; int cmp(E e1,E e2){ return e1.w>e2.w; } int find( int x){ if (x!=t[x]) return t[x]=find(t[x]); return t[x]; } int main(){ int i,j,k,tc,numE,result,numC,numV,u,v; cin >>numC; for (i=0;i<numC;i++){ result=numE=0; for (i=0;i<501;i++) t[i]=i; cin >>numV; for (j=0;j<numV;j++){ for (k=0;k<numV;k++){ e[numE].p=j; e[numE].n=k; scanf("%d",&(e[numE++].w)); } } tc=numE; make_heap(e,e+numE,cmp); result=e[0].w; for (i=0;i<numV;tc--){ if(!tc) break; if ((u=find(e[0].p)) != (v=find(e[0].n))){ t[u]=v; if (result<e[0].w) result=e[0].w; i++; } pop_heap(e,e+tc,cmp); } cout <<result<<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