func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int c[301];   vector<int> a[301];   vector<int> lt[301];   int id[301];   int dem = 0;   int d[301];   void nhap() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &c[i]);       id[c[i]] = i;     }     for (int i = 1; i <= n; i++) {       string s;       cin >> s;       for (int j = 0; j < s.length(); j++) {         if (s[j] ==  1 ) {           int u = c[i];           int v = c[j + 1];           a[u].push_back(v);           a[v].push_back(u);         }       }     }   }   void bfs(int s) {     queue<int> q;     q.push(s);     dem++;     d[s] = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       lt[dem].push_back(u);       for (vector<int>::iterator i = a[u].begin(); i != a[u].end(); i++) {         if (d[*i] == 0) {           d[*i] = 1;           q.push(*i);         }       }     }   }   void xuly(int k) {     priority_queue<int, vector<int>, greater<int> > q;     vector<int> t;     for (auto i : lt[k]) {       q.push(i);       t.push_back(id[i]);     }     sort(t.begin(), t.end());     for (auto i : t) {       c[i] = q.top();       q.pop();     }   }   int main() {     nhap();     for (int i = 1; i <= n; i++) {       if (d[i] == 0) {         bfs(i);       }     }     for (int i = 1; i <= dem; i++) {       xuly(i);     }     for (int i = 1; i <= n; i++) cout << c[i] <<    ;     return 0;   }   