{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eGiven is a connected undirected graph with \u003cvar\u003e\\(N\\)\u003c/var\u003e vertices and \u003cvar\u003e\\(M\\)\u003c/var\u003e edges. The vertices are numbered \u003cvar\u003e\\(1\\)\u003c/var\u003e to \u003cvar\u003e\\(N\\)\u003c/var\u003e, and the edges are described by a grid of characters \u003cvar\u003e\\(S\\)\u003c/var\u003e.\r\nIf \u003cvar\u003e\\(S_{i,j}\\)\u003c/var\u003e is \u003ccode\u003e1\u003c/code\u003e, there is an edge connecting Vertex \u003cvar\u003e\\(i\\)\u003c/var\u003e and \u003cvar\u003e\\(j\\)\u003c/var\u003e; otherwise, there is no such edge.\u003c/p\u003e\r\n\u003cp\u003eDetermine whether it is possible to divide the vertices into non-empty sets \u003cvar\u003e\\(V_1, \\dots, V_k\\)\u003c/var\u003e such that the following condition is satisfied. If the answer is yes, find the maximum possible number of sets, \u003cvar\u003e\\(k\\)\u003c/var\u003e, in such a division.\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eEvery edge connects two vertices belonging to two \"adjacent\" sets. More formally, for every edge \u003cvar\u003e\\((i,j)\\)\u003c/var\u003e, there exists \u003cvar\u003e\\(1\\leq t\\leq k-1\\)\u003c/var\u003e such that \u003cvar\u003e\\(i\\in V_t,j\\in V_{t+1}\\)\u003c/var\u003e or \u003cvar\u003e\\(i\\in V_{t+1},j\\in V_t\\)\u003c/var\u003e holds.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(2 \\leq N \\leq 200\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_{i,j}\\)\u003c/var\u003e is \u003ccode\u003e0\u003c/code\u003e or \u003ccode\u003e1\u003c/code\u003e.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_{i,i}\\)\u003c/var\u003e is \u003ccode\u003e0\u003c/code\u003e.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_{i,j}\u003dS_{j,i}\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eThe given graph is connected.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e is an integer.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_{1,1}...S_{1,N}\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(:\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_{N,1}...S_{N,N}\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eIf it is impossible to divide the vertices into sets so that the condition is satisfied, print \u003cvar\u003e\\(-1\\)\u003c/var\u003e.\r\nOtherwise, print the maximum possible number of sets, \u003cvar\u003e\\(k\\)\u003c/var\u003e, in a division that satisfies the condition.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n01\r\n10\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eWe can put Vertex \u003cvar\u003e\\(1\\)\u003c/var\u003e in \u003cvar\u003e\\(V_1\\)\u003c/var\u003e and Vertex \u003cvar\u003e\\(2\\)\u003c/var\u003e in \u003cvar\u003e\\(V_2\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n011\r\n101\r\n110\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\n010110\r\n101001\r\n010100\r\n101000\r\n100000\r\n010000\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\u003c/section\u003e\r\n"}}]}