func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = ~0ULL >> 1;   const int maxV = 3e5 + 10;   const int maxE = 6e5 + 10;   struct EDGE {     int v, nxt;     long long w;     EDGE() {}     EDGE(int vv, int xx, long long ww) { v = vv, nxt = xx, w = ww; }   };   EDGE edg[maxE];   int EH[maxV], etot;   void initG() {     memset(EH, -1, sizeof(EH));     etot = 0;   }   void addEdge(int u, int v, long long w) {     edg[etot] = EDGE(v, EH[u], w);     EH[u] = etot++;   }   int n, m;   short an[maxE];   long long dist[maxV];   short vs[maxV];   struct Node {     int src, id;     long long dst;     Node() {}     Node(int ss, long long dd, int ii) { src = ss, dst = dd, id = ii; }     bool operator<(const Node &rhs) const {       return (rhs.dst < dst) || (dst == rhs.dst && edg[rhs.id].w < edg[id].w);     }   };   void spfa(int s) {     for (int i = 1; i <= n; i++) dist[i] = inf;     memset(vs, 0, sizeof(vs));     memset(an, 0, sizeof(an));     priority_queue<Node> que;     dist[s] = 0;     que.push(Node(s, dist[s], -1));     long long rs = 0;     while (!que.empty()) {       Node now = que.top();       que.pop();       int u = now.src;       int id = now.id;       if (vs[u]) continue;       vs[u] = 1;       if (id != -1) {         rs += edg[id].w;         an[id] = 1;       }       for (int p = EH[u]; ~p; p = edg[p].nxt) {         int v = edg[p].v;         long long w = edg[p].w;         if (dist[v] >= dist[u] + w) {           dist[v] = dist[u] + w;           que.push(Node(v, dist[v], p));         }       }     }     cout << rs << endl;     m <<= 1;     for (int i = 0; i < m; i++)       if (an[i]) cout << (i / 2 + 1) <<    ;     cout << endl;   }   int main() {     int u, v, p;     long long w;     while (~scanf( %d%d , &n, &m)) {       initG();       for (int i = 1; i <= m; i++) {         scanf( %d%d%I64d , &u, &v, &w);         addEdge(u, v, w);         addEdge(v, u, w);       }       scanf( %d , &p);       spfa(p);     }     return 0;   }   