Havel Theorem
Modular functions
# Include <iostream>
# Include <algorithm>
Using namespace STD;
Struct Node
{
Int degree;
Int index;
};
Node Lake [20];
Int la [20] [20];
Int N;
Bool compare (node A, Node B)
{
Return A. degree> B. degree;
}
Void input ()
{
For (INT I = 0; I <n; I ++)
{
Cin> Lake [I]. degree;
Lake [I]. Index = I;
}
}
Bool judge ()
{
Memset (La, 0, sizeof (LA ));
For (INT I = 0; I <n-1; I ++)
{
Sort (Lake + I, Lake + N, compare );
/* For (int K = 0; k <n; k ++)
{
Cout <Lake [K]. index <"";
}
Cout <Endl ;*/
If (Lake [I]. Degree = 0)
Return true;
For (Int J = I + 1; j <n; j ++)
{
If (Lake [I]. degree> 0) & (Lake [J]. degree> 0) & (La [Lake [I]. index] [Lake [J]. index] = 0 ))
{
Lake [I]. degree --;
Lake [J]. degree --;
La [Lake [I]. Index] [Lake [J]. Index] = 1;
La [Lake [J]. Index] [Lake [I]. Index] = 1;
}
}
If (Lake [I]. degree! = 0)
Return false;
}
}
Void output ()
{
For (INT I = 0; I <n; I ++)
{
For (Int J = 0; j <n; j ++)
Cout <la [I] [J] <"";
Cout <Endl;
}
}
Int main ()
{
Int T;
Cin> T;
While (t)
{
Cin> N;
Input ();
If (Judge ())
{
Cout <"yes" <Endl;
Output ();
}
Else
Cout <"no" <Endl;
T --;
If (T! = 0)
Cout <Endl;
}
Return 0;
}