func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   long long INF = 1e18;   int n, s;   vector<int> ans;   long long ansV = 0;   long long dis[N];   int edge[N], val[N];   vector<pair<int, int> > adj[N];   void solve() {     for (int i = 1; i <= n; i++) dis[i] = INF;     priority_queue<pair<long long, int>, vector<pair<long long, int> >,                    greater<pair<long long, int> > >         pq;     dis[s] = 0;     pq.push({dis[s], s});     while (!pq.empty()) {       int u = pq.top().second;       long long Cost = pq.top().first;       pq.pop();       if (Cost > dis[u]) continue;       if (u != s) {         ans.push_back(edge[u]);         ansV += val[edge[u]];       }       for (auto P : adj[u]) {         int v = P.first, idx = P.second;         if (Cost + val[idx] < dis[v]) {           dis[v] = Cost + val[idx];           edge[v] = idx;           pq.push({dis[v], v});         } else if (Cost + val[idx] == dis[v] && val[idx] < val[edge[v]])           edge[v] = idx;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v >> val[i];       adj[u].push_back({v, i});       adj[v].push_back({u, i});     }     cin >> s;     solve();     sort(ans.begin(), ans.end());     cout << ansV << endl;     for (auto v : ans) cout << v + 1 <<    ;     cout << endl;     return 0;   }   