🏡 index : github.com/captn3m0/codechef.git

{"category_name":"easy","status":"success","problem_code":"DEVLDISC","problem_name":"Devu and a light discussion","body":"<span class=\"solution-visible-txt\">All submissions for this problem are available.<\/span><h3> Read problems statements in <a target=\"_blank\" href=\"http:\/\/www.codechef.com\/download\/translated\/FEB16\/mandarin\/DEVLDISC.pdf\">Mandarin Chinese<\/a>, <a target=\"_blank\" href=\"http:\/\/www.codechef.com\/download\/translated\/FEB16\/russian\/DEVLDISC.pdf\">Russian<\/a> and <a target=\"_blank\" href=\"http:\/\/www.codechef.com\/download\/translated\/FEB16\/vietnamese\/DEVLDISC.pdf\">Vietnamese<\/a> as well.<\/h3>\n\n\n<p>\nOne day, Devu and Churu were involved in a light discussion about finding the diameter of an undirected unweighted connected graph. Diameter of a graph is the maximum value of pairwise shortest distances over all pairs of vertices of the graph. Churu proposed the following algorithm which takes a parameter <tt><b>start_vertex<\/b><\/tt>.\n\n<pre><tt>\nAlgorithm (<b>start_vertex<\/b>):\n\tfind out the set of vertices <b>S<\/b> having maximum value of \n\t\tshortest distance from <b>start_vertex<\/b>.\n\tans = 0;\n\tfor each vertex v in <b>S<\/b>\n\t\ttemp = 0;\n\t\tfor each vertex u in graph G:\n\t\t\ttemp = max(temp, shortest distance between u and v).\n\t\tans = max(ans, temp);\n\treturn ans;\n<\/tt><\/pre>\n<\/p>\n\n<p>\nWhen Devu heard this algorithm, he exclaimed: \"What, this does not seem to be correct!\". Churu challenged him to give a counter example to disprove the algorithm. You have to help Devu come up with a graph as a counter example to the above algorithm, if one exists.\n<\/p>\n\n<p>\nFormally, You will be given an integer <b>n<\/b> denoting the number of nodes of the expected graph (counter example Devu is producing). The graph should be undirected, unweighted and connected. The actual diameter of the graph should not be equal to the one returned by the Churu's proposed algorithm. \n\nIf for the given <b>n<\/b>, there does not exist any such graph which could act as counter example, print -1.\n<\/p>\n\n<h3>Input<\/h3>\n<ul>\n<li>The first line of input contains a single integer <b>T<\/b> denoting number of test cases. Description of <b>T<\/b> test cases follows.<\/li>\n<li>Only line of each test case contains a single integer <b>n<\/b> as defined in the problem statement.<\/li>\n<\/ul>\n\n<h3>Output<\/h3>\n<ul>\n<li>For each test case, first line should contain the number of edges in the counter-example graph, or -1 if no counter-example exists.<\/li>\nIf a counter example exists, then:\n<li>Print a single line containing an integer <b>m<\/b> denoting the number of edges in the desired graph<\/li>\n<li>Print <b>m<\/b> lines, each line should contain two integers <b>u<\/b> and <b>v<\/b> (1-based indexing) denoting an edge of the graph. You should make sure that no two edges in the graph repeat, and that the graph is connected.<\/li>\n<li>In the next line, print a single integer denoting <tt><b>start_vertex<\/b><\/tt> (1-based indexing) passed to the algorithm.<\/li>\n<\/ul>\n\n<h3>Constraints<\/h3>\n<ul>\n<li><b>1 \u2264 T, n \u2264 50<\/b><\/li>\n<\/ul>\n\n<h3>Subtask<\/h3>\nThere is only a single subtask worth 100 points with above mentioned constraints.\n\n<h3>Example<\/h3>\n<pre><b>Input:<\/b>\n2\n2\n10\n<b>Output:<\/b>\n-1\n9\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n7\n<\/pre>\n\n<h3>Explanation<\/h3>\n<p><b>Example case 1.<\/b> There can be only one connected graph of 2 nodes. (i.e. 1 is connected to 2). Diameter returned by algorithm for any start vertex will be 1 which is equal to the actual diameter. So answer is -1.\n<\/p>\n<p><b>Example case 2.<\/b> Please note that example given for <b>n = 10<\/b> is <b>not a correct counter example<\/b>. It is only given so as to clarify the input output format. In the example, first line contains <b>9<\/b> denoting the number of edges in the graph. Then <b>9<\/b> edges of the graph are given. The graph is connected. Then the last line specifies the value of <tt><b>start_vertex<\/b><\/tt> passed (that is, <b>7<\/b>) to Churu's algorithm.<\/p>","languages_supported":"ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC","max_timelimit":"1","source_sizelimit":"50000","problem_author":"admin2","problem_author_html_handle":"admin2","problem_tester":"iscsi","problem_tester_html_handle":"<span \n            class='rating' \n            style='display: inline-block; \n                    font-size: 10px; \n                    background: #FF7F00;\n                    padding: 0 3px; \n                    line-height: 1.3; \n                    color: white;\n                    margin-right: 2px;'>6&#9733;<\/span><span>iscsi<\/span>","date_added":"3-03-2015","tags":"<a class='problem-tag-small ' href='\/tags\/problems\/ad-hoc'>\n                    ad-hoc\n                <\/a><a class='problem-tag-small ' href='\/tags\/problems\/admin2'>\n                    admin2\n                <\/a><a class='problem-tag-small ' href='\/tags\/problems\/feb16'>\n                    feb16\n                <\/a><a class='problem-tag-small ' href='\/tags\/problems\/graph'>\n                    graph\n                <\/a><a class='problem-tag-small ' href='\/tags\/problems\/simple'>\n                    simple\n                <\/a>","editorial_url":"http:\/\/discuss.codechef.com\/problems\/DEVLDISC","user":{"username":null},"time":{"view_start_date":1455528600,"submit_start_date":1455528600,"visible_start_date":1455528600,"end_date":1735669800,"current":1493558135},"todo":false,"problem_status":"unattempted"}