func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, cnt;   char s[2100][2100], ans[2100][2100];   int tp[2100 << 1];   bitset<2100> a[2100], a1;   unsigned long long b1[2100], b2[2100];   int v1[2100][2100], v2[2100][2100], v3[2100][2100], mp[2100][2100],       lk[2100][2100];   int num[2100], beg[2100], ed[2100], vis[2100], bel[2100], lm[2100], rm[2100],       fa[2100], deep[2100];   vector<int> son[2100];   struct node {     int lb, rb;     vector<int> vec, lp, rp;     vector<bitset<2100> > bs;     friend bool operator<(const node &r1, const node &r2) {       if (r1.rb - r1.lb == r2.rb - r2.lb) return r1.vec.size() > r2.vec.size();       return r1.rb - r1.lb < r2.rb - r2.lb;     };     void cal() {       int cnt = 0;       for (int i = 0; i < vec.size(); i++) {         tp[++cnt] = beg[vec[i]];         tp[++cnt] = ed[vec[i]] + 1;       }       sort(tp + 1, tp + 1 + cnt);       cnt = unique(tp + 1, tp + 1 + cnt) - tp - 1;       for (int i = 1; i < cnt; i++) {         lp.push_back(tp[i]);         rp.push_back(tp[i + 1] - 1);         bs.push_back(a[0]);         for (int j = 0; j < vec.size(); j++)           bs[i - 1][vec[j]] =               !(beg[vec[j]] > tp[i + 1] - 1 || tp[i] > ed[vec[j]]);       }     }   } p[2100];   void quit() {     puts( NO );     exit(0);   }   int check(int x) {     for (int i = 1; i <= n; i++)       if (i != x && deep[i] && bel[x] == bel[i]) {         int t2 = 0, t3 = 0;         if (beg[x] > ed[i] || beg[i] > ed[x])           t2 = num[i], t3 = num[x];         else {           if (beg[x] > beg[i]) t2 += beg[x] - beg[i];           if (ed[i] > ed[x]) t2 += ed[i] - ed[x];           if (beg[i] > beg[x]) t3 += beg[i] - beg[x];           if (ed[x] > ed[i]) t3 += ed[x] - ed[i];         }         if (t2 != v2[i][x] || t3 != v3[i][x]) return 0;       }     return 1;   }   void dfs(int x, int y, int org) {     deep[x] = deep[y] + 1;     bel[x] = org;     if (!y) {       beg[x] = 1;       ed[x] = num[x];       p[bel[x]].lb = beg[x];       p[bel[x]].rb = ed[x];     } else {       bel[x] = bel[y];       beg[x] = beg[y] + v2[y][x];       ed[x] = beg[x] + num[x] - 1;       if (!check(x)) {         beg[x] = beg[y] - v3[y][x];         ed[x] = beg[x] + num[x] - 1;         if (!check(x)) quit();       }       p[bel[x]].lb = min(p[bel[x]].lb, beg[x]);       p[bel[x]].rb = max(p[bel[x]].rb, ed[x]);     }     for (int i = 1; i <= n; i++)       if (mp[x][i] && !deep[i]) dfs(i, x, org);     p[bel[x]].vec.push_back(x);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     n++;     for (int i = 1; i <= n; i++) s[n][i] =  1 ;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) a[i][j] = (s[i][j] ==  1 );       num[i] = a[i].count();       for (int j = 1; j <= n; j++) b1[i] = b1[i] * 10007 + (s[j][i] ==  1 );     }     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++) {         a1 = a[i] & a[j];         v1[i][j] = v1[j][i] = a1.count();         v2[i][j] = v3[j][i] = num[i] - v1[i][j];         v3[i][j] = v2[j][i] = num[j] - v1[i][j];         if (v2[i][j] && v3[i][j] && v1[i][j]) mp[i][j] = mp[j][i] = 1;       }     for (int i = 1; i <= n; i++)       if (!bel[i] && num[i]) dfs(i, 0, ++cnt);     sort(p + 1, p + 1 + cnt);     for (int i = 1; i <= cnt; i++)       for (int j = 0; j < p[i].vec.size(); j++) bel[p[i].vec[j]] = i;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (v1[i][j]) lk[bel[i]][bel[j]] = 1;     for (int i = 1; i <= cnt; i++) {       for (int j = i + 1; j <= cnt; j++)         if (lk[i][j]) {           fa[i] = j;           break;         }     }     for (int i = cnt; i >= 1; i--) {       if (fa[i]) {         int t = p[i].vec[0], l1 = p[fa[i]].lb, r1 = p[fa[i]].rb;         a1.reset();         for (int j = 0, t1; j < p[fa[i]].vec.size(); j++) {           t1 = p[fa[i]].vec[j];           a1[t1] = (v1[t][t1] ? 1 : 0);         }         if (l1 > r1) quit();         for (int j = 0; j < p[fa[i]].lp.size(); j++)           if (p[fa[i]].bs[j] == a1) {             int l2 = p[fa[i]].lp[j], r2 = p[fa[i]].rp[j];             if (l2 > r2) continue;             if (r2 - l2 + 1 < p[i].rb - p[i].lb + 1) continue;             int det = l2 - p[i].lb;             for (int k = 0, t; k < p[i].vec.size(); k++) {               t = p[i].vec[k];               beg[t] += det;               ed[t] += det;             }             p[i].lb += det;             p[i].rb += det;             p[fa[i]].lp[j] += p[i].rb - p[i].lb + 1;             break;           }       }       p[i].cal();     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) ans[i][j] =  0 ;       if (num[i])         for (int j = beg[i]; j <= ed[i]; j++) ans[i][j] =  1 ;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) b2[i] = b2[i] * 10007 + (ans[j][i] ==  1 );       int flag = 0;       for (int j = 1; j <= n; j++)         if (!vis[j] && b2[i] == b1[j]) {           flag = 1;           vis[j] = 1;           break;         }       if (!flag) quit();     }     puts( YES );     for (int i = 1; i < n; i++) {       for (int j = 1; j < n; j++) putchar(ans[i][j]);       puts(  );     }     return 0;   }   