{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":" This is the moment you\u0027ve been waiting for all your life: you\u0027ve invented a way to quickly solve the Maximal Clique problem: given an undirected graph find the size of the maximal subset of its vertices that form a clique (are pairwise connected). This problem is NP-hard, meaning you\u0027ve got a proof that P\u003dNP!\u003cbr\u003eUnfortunately, the scientific community is not so eager to listen to you. Your papers on the subject are being rejected because of \"solving an obviously unsolvable problem\". Your phone number is already on the ignore list of all Computer Science professors you know. The world seems to hate you.\u003cbr\u003eSo you\u0027ve decided to create a solver for the Maximal Clique problem and put it online, so that everyone can check for himself that you\u0027re right. You\u0027ve already implemented the solver and almost launched the website, but then you\u0027ve realized that this is not a very good idea: if you make the solver available, everyone will be able to solve every problem from NP by reducing it to the Maximal Clique problem. What if people will just silently use it instead of bringing you fame and respect?\u003cbr\u003eLuckily, the only proof of NP-hardness of the Maximal Clique problem you know works by reducing the 3-SAT problem to it in a very specific way. So you\u0027ve decided to check if the input graph given to your solver could be obtained from this reduction, and if yes, refuse to solve the problem. That way, nobody will be able to get quick solutions for all problems from NP, but everyone will still be able to verify your solver by feeding other graphs to it.\u003cbr\u003e3-SAT problem statement is: given a formula of form \u003cimg src\u003d\"CDN_BASE_URL/b10c595df3573e8c2c9eecbbb9d171c9?v\u003d1716043647\" style\u003d\"vertical-align: text-bottom;top: -2.0px;max-width: 100.0%;max-height: 100.0%;\"\u003e, where each term \u003ci\u003et\u003c/i\u003e\u003csub\u003e\u003ci\u003ej\u003c/i\u003e\u003c/sub\u003e\u003csup\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sup\u003e is either some boolean variable or its negation (more formally, either \u003ci\u003ex\u003c/i\u003e\u003csub\u003e\u003ci\u003ek\u003c/i\u003e\u003c/sub\u003e or \u003cimg src\u003d\"CDN_BASE_URL/cfce0457d047db979e7de630e2b753c2?v\u003d1716043647\" style\u003d\"vertical-align: text-bottom;top: -2.0px;max-width: 100.0%;max-height: 100.0%;\"\u003e), check whether there exists some assignment of true/false values to each variable so that the formula evaluates to true. All three terms in one clause must represent different variables.\u003cbr\u003eThe reduction works in the following manner. From the above formula, we create a graph with 3n vertices, one for each variable of each clause. Two vertices corresponding to terms \u003ci\u003et\u003c/i\u003e\u003csub\u003e\u003ci\u003ej\u003c/i\u003e\u003c/sub\u003e\u003csup\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sup\u003e and \u003ci\u003et\u003c/i\u003e\u003csub\u003e\u003ci\u003es\u003c/i\u003e\u003c/sub\u003e\u003csup\u003e\u003ci\u003er\u003c/i\u003e\u003c/sup\u003e are connected when \u003ci\u003ei\u003c/i\u003e ≠ \u003ci\u003er\u003c/i\u003e (so the terms belong to different clauses) and those terms are non-contradictory (they are either equal or represent different variables).\u003cbr\u003eThe following picture shows the resulting graph for the formula \u003cimg src\u003d\"CDN_BASE_URL/90b056fb23b4a41a246135c3dfa5d258?v\u003d1716043647\" style\u003d\"vertical-align: text-bottom;top: -2.0px;max-width: 100.0%;max-height: 100.0%;\"\u003e:\u003cbr\u003e\u003cdiv style\u003d\"text-align: center;margin-bottom: 1.0em;\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/16595b458432801da86984cf0f04a4b7?v\u003d1716043647\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/div\u003eNow a clique of size \u003ci\u003en\u003c/i\u003e corresponds to a valid true/false assignment that satisfies at least one term in each clause. The edges highlighted on the above picture form a clique of size 3 and show that setting \u003ci\u003ex\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e to false and \u003ci\u003ex\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e to true satisfies all clauses, irrespective of the values of \u003ci\u003ex\u003c/i\u003e\u003csub\u003e3\u003c/sub\u003e and \u003ci\u003ex\u003c/i\u003e\u003csub\u003e4\u003c/sub\u003e.\u003cbr\u003eGiven a graph, you need to check if it could be created by the above reduction. The vertices are permuted arbitrarily.\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/div\u003eThe first line of the input file contains two integers \u003ci\u003ev\u003c/i\u003e and \u003ci\u003ee\u003c/i\u003e, 1 ≤ \u003ci\u003ev\u003c/i\u003e ≤ 100, denoting the number of vertices and edges in the graph. The next \u003ci\u003ee\u003c/i\u003e lines contain two integers each, denoting the numbers of vertices connected by an edge. Each pair of vertices are connected at most once, no edge connects a vertex to itself.\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/div\u003eOutput \"YES\" when the given graph could be obtained by the given reduction, or \"NO\" otherwise.\u003cbr\u003e"}},{"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\u003e9 22\n1 3\n1 6\n7 1\n8 9\n9 1\n2 3\n2 4\n2 5\n2 6\n2 8\n3 4\n3 5\n3 7\n4 8\n4 9\n5 6\n5 7\n5 8\n5 9\n6 7\n6 9\n7 8\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}