func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> vec[200005];   queue<int> Q;   int n, m;   int cvp[200005];   int top[200005], in[200005];   int a[200005], b[200005], c[200005];   void oku() {     int f, s, cost, i;     scanf( %d %d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d %d %d , &f, &s, &cost);       vec[f].push_back(i);       vec[s].push_back(i);       a[i] = f;       b[i] = s;       c[i] = cost;       top[f] += cost;       top[s] += cost;     }     return;   }   void coz() {     int nod, s;     vector<int>::iterator it;     memset(cvp, -1, sizeof cvp);     Q.push(1);     while (!Q.empty()) {       nod = Q.front();       Q.pop();       for (it = vec[nod].begin(); it != vec[nod].end(); it++)         if (cvp[*it] == -1) {           if (nod == b[*it])             s = a[*it];           else             s = b[*it];           cvp[*it] = (nod == b[*it]);           in[s] += c[*it];           if (s != n && top[s] == 2 * in[s]) Q.push(s);         }     }     for (int i = 1; i <= m; i++) printf( %d n , cvp[i]);     return;   }   int main() {     oku();     coz();     return 0;   }   