func_code_string: #include <bits/stdc++.h>   using namespace std;   int dis[305][305], lca[305], val[305];   int main() {     int n, x;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &x);       lca[x] = i;       val[i] = x;     }     char s[305];     memset(dis, 0, sizeof dis);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= n; j++)         if (s[j] ==  1 ) dis[i][j] = dis[j][i] = 1;     }     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           if (dis[i][j] == 0) dis[i][j] = dis[i][k] & dis[k][j];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (dis[i][lca[j]] == 0) continue;         val[lca[j]] = val[i];         lca[val[i]] = lca[j];         val[i] = j;         lca[j] = i;       }     for (int i = 1; i <= n; i++) printf( %d%s , val[i], i == n ?   n  :    );     return 0;   }   