func_code_string: #include <bits/stdc++.h>   using namespace std;   bitset<510> reach[510];   int n, p[510], use[510], i, j, wz[510];   char s[510];   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &p[i]), wz[p[i]] = i;     for (i = 1; i <= n; i++) {       scanf( %s , s + 1);       reach[i][i] = 1;       for (j = 1; j <= n; j++)         if (s[j] ==  1 ) reach[i][j] = 1;     }     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++)         if (reach[j][i]) reach[j] |= reach[i];     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++)         if (!use[j] && reach[i][wz[j]]) break;       use[j] = 1;       printf( %d  , j);     }   }   