func_code_string: #include <bits/stdc++.h>   using namespace std;   struct ee {     int x, y, w;   };   vector<int> ke[300010], kq;   int n, m, s, c[300010] = {0}, p[300010], b[300010];   ee e[300010];   priority_queue<pair<long long, int> > Q;   long long d[300010];   void enter() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       scanf( %d%d%d , &e[i].x, &e[i].y, &e[i].w);       ke[e[i].x].push_back(i);       ke[e[i].y].push_back(-i);     }     scanf( %d , &s);   }   void dijkstra() {     for (int i = 1; i <= n; ++i) d[i] = 1e18;     d[s] = 0;     Q.push(pair<long long, int>(0, s));     int u, v;     long long w;     while (!Q.empty()) {       u = Q.top().second;       w = -Q.top().first;       Q.pop();       if (d[u] != w) continue;       for (vector<int>::iterator i = ke[u].begin(); i != ke[u].end(); ++i) {         v = (*i > 0 ? e[*i].y : e[-*i].x);         if (w + e[abs(*i)].w < d[v]) {           d[v] = w + e[abs(*i)].w;           Q.push(pair<long long, int>(-d[v], v));           p[v] = abs(*i);         } else if (w + e[abs(*i)].w == d[v] && e[abs(*i)].w < e[p[v]].w)           p[v] = abs(*i);       }     }   }   bool compare(int i, int j) { return e[i].w < e[j].w; }   int Find(int u) {     if (p[u] < 0) return u;     return p[u] = Find(p[u]);   }   void process() {     long long ans = 0;     int t;     for (int i = 1; i <= m; ++i)       if (abs(d[e[i].x] - d[e[i].y]) != e[i].w)         continue;       else {         t = (d[e[i].x] > d[e[i].y] ? e[i].x : e[i].y);         if (i != p[t]) continue;         ans += e[i].w;         kq.push_back(i);       }     cout << ans <<   n ;     for (vector<int>::iterator i = kq.begin(); i != kq.end(); ++i)       printf( %d  , *i);   }   int main() {     enter();     dijkstra();     process();     return 0;   }   