func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   vector<pair<int, bool> > adj[maxn];   vector<pair<pair<int, int>, bool> > edge;   int dp[maxn], dis[maxn], par[maxn];   bool mark[maxn], in_path[maxn];   int n, m, ans = 0;   void input() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b, w;       cin >> a >> b >> w;       adj[a - 1].push_back(make_pair(b - 1, 1 - w));       adj[b - 1].push_back(make_pair(a - 1, 1 - w));       edge.push_back(make_pair(make_pair(a - 1, b - 1), 1 - w));       if (w) ans++;     }   }   void bfs() {     queue<int> q;     q.push(0);     mark[0] = true;     dis[0] = 0;     dp[0] = 0;     while (!q.empty()) {       int v = q.front();       q.pop();       for (auto u : adj[v]) {         if (!mark[u.first]) {           q.push(u.first);           mark[u.first] = true;           dis[u.first] = dis[v] + 1;           par[u.first] = v;           dp[u.first] = dp[v] + u.second;         } else if ((dp[u.first] > dp[v] + u.second) &&                    (dis[u.first] == dis[v] + 1)) {           par[u.first] = v;           dp[u.first] = dp[v] + u.second;         }       }     }   }   void check() {     for (int i = 0; i < n; i++) cout <<  par   << par[i] << endl;   }   void pp(int v) {     if (par[v] == v) return;     in_path[v] = true;     pp(par[v]);   }   void output() {     cout << ans - dis[n - 1] + 2 * dp[n - 1] << endl;     in_path[0] = true;     in_path[n - 1] = true;     pp(n - 1);     for (int i = 0; i < m; i++) {       int a = edge[i].first.first, b = edge[i].first.second, w = edge[i].second;       if (!in_path[a] || !in_path[b])         if (!w) cout << a + 1 <<     << b + 1 <<     << w << endl;       if (in_path[a] && in_path[b])         if (w) cout << a + 1 <<     << b + 1 <<     << w << endl;     }     return;   }   int main() {     input();     bfs();     output();     return 0;   }   