| ||You are given an undirected graph with n vertices numbered 0 through n-1.
For each valid i, there is an undirected edge connecting two different vertices x[i] and y[i].
No two edges connect the same pair of vertices.|
A triangle is a set of three distinct vertices such that each pair of those vertices is connected by an edge.
Formally, three distinct vertices u,v,w are a triangle if the graph contains the edges (u,v), (v,w), and (w,u).
You are given the description of the graph: the int n and the ints x and y.
You are allowed to add edges to this graph.
You may add as many edges as you want, and each of them may connect any two vertices.
Your goal is to produce a graph that contains at least one triangle.
Compute and return the smallest number of edges you need to add.
|Parameters:||int, int, int|
|Method signature:||int find(int n, int x, int y)|
|(be sure your method is public)|
|-||n will be between 3 and 50, inclusive.|
|-||x will have between 0 and n*(n-1)/2 elements, inclusive.|
|-||y will have the same number of elements as x.|
|-||Each element of x and y will be between 0 and n-1, inclusive.|
|-||For each valid i, x[i] != y[i].|
|-||No two edges will connect the same pair of vertices.|
|The graph has three vertices but no edges. You need to add edges (0,1), (1,2), and (2,0) to make it a triangle.
|Note that the edges are undirected. The graph already has a triangle: (2,0),(0,3),(2,3), so we don't have to add anything.
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.