#include <bits/stdc++.h>
using namespace std;
const int maxn=61*30+5;
int cntIdx;
bool dp[32][62][maxn],graph[62][62];
short int track[32][62][maxn];
pair<int,int> Scnt[62];
int main()
{
int M,A[32];
cin>>M;
for(int i=1;i<=M;++i)
cin>>A[i];
sort(A+1,A+M+1);
dp[0][0][0]=true;
for(int i=1;i<=M;++i)
for(int j=i;j<=61;++j)
for(int k=(j*(j-1))>>1;k<maxn;++k)
{
for(int m=1;m<=j;++m)
if(k>=m*A[i] && dp[i-1][j-m][k-m*A[i]])
{
dp[i][j][k]=true;
track[i][j][k]=m;
break;
}
}
int N=M;
while(!dp[M][N][(N*(N-1))>>1]) ++N;
cout<<N<<"\n";
for(int i=M,j=N,k=(N*(N-1))>>1;i;--i){
int c=track[i][j][k];
j-=c;
k-=c*A[i];
for(int j=0;j<c;++j){
++cntIdx;
Scnt[cntIdx]=make_pair(A[i],cntIdx);
}
}
for(int i=1;i<=N;++i){
sort(Scnt+1,Scnt+cntIdx+1);
for(int j=i+1;j<=i+Scnt[i].first;++j) graph[Scnt[i].second][Scnt[j].second]=true;
for(int j=i+Scnt[i].first+1;j<=N;++j) graph[Scnt[j].second][Scnt[i].second]=true,--Scnt[j].first;
Scnt[i].first=-1;
}
for(int i=1;i<=N;++i){
for(int j=1;j<=N;++j)
cout<<(graph[i][j]?1:0);
cout<<"\n";
}
return 0;
}/*1695971235.0255582*/
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |