func_code_string: #include <bits/stdc++.h>   using namespace std;   struct yts {     int v[300010], ne[2 * 300010], x[2 * 300010], y[2 * 300010];     bool val[2 * 300010];     int num;     void put(int s, int t) {       num++;       x[num] = s;       y[num] = t;       ne[num] = v[s];       v[s] = num;     }   } e1, e2;   int q[300010];   bool vis[300010];   char dir[300010];   int S, n, m, undir;   char ty(int x) { return (x & 1) ?  -  :  + ; }   void bfs(int type) {     int h = 0, w = 1;     q[1] = S;     vis[S] = 1;     while (h != w) {       int x = q[++h];       for (int i = e2.v[x]; i; i = e2.ne[i]) {         if (!dir[i >> 1]) {           if (type == 1)             e2.val[i] = 1, e2.val[i ^ 1] = 0, dir[i >> 1] = ty(i);           else             e2.val[i] = 0, e2.val[i ^ 1] = 1, dir[i >> 1] = ty(i ^ 1);         }       }       for (int i = e2.v[x]; i; i = e2.ne[i])         if (e2.val[i]) {           int y = e2.y[i];           if (!vis[y]) vis[y] = 1, q[++w] = y;         }       for (int i = e1.v[x]; i; i = e1.ne[i]) {         int y = e1.y[i];         if (!vis[y]) vis[y] = 1, q[++w] = y;       }     }     int ans = 0;     for (int i = 1; i <= n; i++) ans += vis[i];     printf( %d n , ans);     for (int i = 1; i <= undir; i++) putchar(dir[i] ? dir[i] :  + );     puts(  );     memset(vis, 0, sizeof(vis));     memset(dir, 0, sizeof(dir));     memset(e2.val, 0, sizeof(e2.val));   }   int main() {     scanf( %d%d%d , &n, &m, &S);     e2.num = 1;     for (int i = 1; i <= m; i++) {       int x, y, ty;       scanf( %d%d%d , &ty, &x, &y);       if (ty == 1)         e1.put(x, y);       else {         undir++;         e2.put(x, y);         e2.put(y, x);       }     }     bfs(1);     bfs(2);     return 0;   }   