Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //F means for!
- #define MX 128
- struct nd{
- nd(int a,double w):t(a),w(w){};
- int t;
- double w;
- bool operator<(const nd&r)const{return w>r.w;}
- };
- int cn[MX],N,m;
- double g[MX][MX];
- double spt(void){
- double S(0);
- memset(cn,0,sizeof(cn));
- cn[0]=1;
- priority_queue<nd> q;
- for(int i(1);i<N;++i)
- q.push(nd(i,g[0][i]));
- while(!q.empty()){
- S+=q.top().w;
- int a(q.top().t);
- cn[a]=1;
- F(N)q.push(nd(i,g[a][i]));
- while(!q.empty()&&cn[q.top().t])
- q.pop();
- }
- return S;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement