func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   vector<int> level[MAXN];   vector<pair<int, int>> adj[MAXN];   vector<pair<int, pair<int, int>>> edges;   int dp[MAXN], d[MAXN], prv[MAXN];   bool OnPath[MAXN];   int main() {     int n, m, a, b, c, cnt = 0;     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       scanf( %d%d%d , &a, &b, &c);       adj[a].push_back(make_pair(b, c));       adj[b].push_back(make_pair(a, c));       edges.push_back({a, {b, c}});       cnt += c;     }     memset(d, -1, sizeof(d));     memset(dp, -1, sizeof(dp));     memset(prv, -1, sizeof(prv));     queue<int> q;     d[1] = dp[1] = 0;     q.push(1);     while (!q.empty()) {       int cur = q.front();       q.pop();       for (auto p : adj[cur]) {         if (d[p.first] == -1) {           d[p.first] = d[cur] + 1;           q.push(p.first);         }       }     }     for (int i = 1; i <= n; i++) level[d[i]].push_back(i);     for (int i = 1; i <= d[n]; i++) {       for (int node : level[i]) {         for (auto p : adj[node]) {           int child = p.first;           if (d[child] == i - 1 && dp[child] + p.second > dp[node]) {             dp[node] = p.second + dp[child];             prv[node] = child;           }         }       }     }     int cur = n;     while (cur != -1) {       OnPath[cur] = 1;       cur = prv[cur];     }     int k = d[n] - dp[n] + cnt - dp[n];     printf( %d n , k);     for (int i = 0; i < m; i++) {       a = edges[i].first, b = edges[i].second.first, c = edges[i].second.second;       if (OnPath[a] && OnPath[b] && !c) printf( %d %d 1 n , a, b);       if ((!OnPath[a] || !OnPath[b]) && c) printf( %d %d 0 n , a, b);     }     return 0;   }   