func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, m;   const long long inf = 0x3f3f3f3f;   const long long size = 100000;   struct data {     long long id, step;     long long x, y, z;     data(){};     data(long long u, long long v) : id(u), step(v){};     data(long long a, long long b, long long c) : x(a), y(b), z(c){};     bool operator<(const data& p) const { return step > p.step; }   };   priority_queue<data> q;   vector<pair<long long, long long> > ve[size + 10];   vector<data> edge;   vector<data> res;   long long dist[size + 10];   long long path[size + 10];   long long TT[size + 10];   bool vis[size + 10];   void init() {     memset(dist, inf, sizeof(dist));     memset(vis, false, sizeof(vis));     memset(path, -1, sizeof(path));     memset(TT, -1, sizeof(TT));     for (int i = 0; i <= n; i++) {       ve[i].clear();     }     edge.clear();     res.clear();     while (!q.empty()) q.pop();   }   void dij() {     dist[1] = 0;     q.push(data(1, dist[1]));     while (!q.empty()) {       data temp = q.top();       q.pop();       if (vis[temp.id])         continue;       else         vis[temp.id] = true;       if (temp.id == n) return;       for (auto u : ve[temp.id]) {         long long v = u.first;         long long color = u.second;         if (!vis[v] && dist[temp.id] + color < dist[v]) {           dist[v] = dist[temp.id] + color;           TT[v] = temp.id;           q.push(data(v, dist[v]));         }       }     }   }   int main() {     long long x, y, z;     init();     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> x >> y >> z;       ve[x].push_back(make_pair(y, !z + size));       ve[y].push_back(make_pair(x, !z + size));       edge.push_back(data(x, y, !z + size));     }     dij();     long long pre = n;     while (pre != 1) {       path[pre] = TT[pre];       pre = TT[pre];     }     for (int i = 0; i < m; i++) {       x = edge[i].x;       y = edge[i].y;       z = edge[i].z;       if (path[x] == y || path[y] == x) {         if (z == size + 1) {           res.push_back(data(x, y, 1LL));         }       } else {         if (z == size) {           res.push_back(data(x, y, 0LL));         }       }     }     cout << res.size() << endl;     for (auto i : res) {       cout << i.x <<     << i.y <<     << i.z << endl;     }     return 0;   }   