func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N(1e5 + 5), M(1e5 + 5);   struct edge {     int u, v, nt, type, flag;   } E[M << 1];   int head[N];   int d[N];   queue<int> que;   void bfs(int s, int *d) {     memset(d, -1, sizeof(int[N]));     que.push(s), d[s] = 0;     while (!que.empty()) {       int u = que.front();       que.pop();       for (int i = head[u]; ~i; i = E[i].nt) {         int &v = E[i].v;         if (~d[v]) continue;         d[v] = d[u] + 1, que.push(v);       }     }   }   int ans;   void find_path(int u, int t, int cnt) {     if (u == t) {       ans = min(ans, cnt);       return;     }     for (int i = head[u]; ~i; i = E[i].nt) {       int &v = E[i].v;       if (d[v] != d[u] + 1) continue;       find_path(v, t, cnt + !E[i].type);     }   }   bool label_path(int u, int t, int cnt) {     if (u == t) return ans == cnt;     for (int i = head[u]; ~i; i = E[i].nt) {       int &v = E[i].v;       if (d[v] != d[u] + 1) continue;       if (label_path(v, t, cnt + !E[i].type)) {         E[i].flag = E[i ^ 1].flag = 1;         return true;       }     }     return false;   }   int main() {     int n, m, good = 0;     scanf( %d%d , &n, &m);     memset(head, -1, sizeof(head));     for (int u, v, type, id = 0, _ = m; _--;) {       scanf( %d%d%d , &u, &v, &type);       E[id] = {u, v, head[u], type, 0}, head[u] = id++;       E[id] = {v, u, head[v], type, 0}, head[v] = id++;       good += type;     }     bfs(1, d);     ans = INT_MAX;     find_path(1, n, 0);     label_path(1, n, 0);     printf( %d n , 2 * ans + good - d[n]);     for (int i = 0; i < 2 * m; i += 2) {       if (E[i].type ^ E[i].flag) printf( %d %d %d n , E[i].u, E[i].v, !E[i].type);     }   }   