Min-hashing

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Consider an undirected simple graph G=(V,E)G = (V, E). The problem of finding a node with similar connectivity is a well-researched topic, because it acts as a good metric to determine which nodes are relevant to other nodes. Services such as "friend recommendation" in Facebook is a good example of its applications. To formalize the notion of similarity, the concept of Jaccard similarity can be used, which is defined as N(v_1)N(v_2)/N(v_1)N(v_2)|N(v\_1) \cap N(v\_2)| / |N(v\_1) \cup N(v\_2)|, where N(v)=u(u,v)EN(v) = \\{u | (u, v) \in E\\}

Here, we will instead discuss the min-hashing method. Assume each node vv has the label l_vl\_v. The shingle value s_vs\_v of node vv is defined as s_v=minl_uuN(v)s\_v = \min \\{l\_u | u \in N(v) \\}. This method is efficient enough to keep up with industrial needs, and it is also a great metric for similarity: the Jaccard similarity between the set of neighbors N(v_1)N(v\_1) and N(v_2)N(v\_2) is an unbiased estimator of the probability that nodes v_1v\_1 and v_2v\_2 have the same shingle values, for random unique labels.

Let's think about a variant of min-hashing: we repeatedly perform min-hashing by taking the label as the previous iteration's shingle value. In this variant, for each node vv and the number of iterations kk, the value h(k)_vh^{(k)}\_v is defined as

h^{(k)}\_v = \begin{cases}\ s\_v, & \text{if $k = 1$}\\\\\ \min \\{h^{(k-1)}\_u | u \in N(v) \\}, & \text{if $k \geq 2$} \\\\\ \end{cases}\

For each kk, let c_kc\_k be the number of unordered pairs of distinct vertices u,v\\{u, v\\} such that h(k)_u=h(k)_vh^{(k)}\_u = h^{(k)}\_v. Then, how does the value c_kc\_k change as kk increases? In this problem, your task is to compute max_k Nc_k\max\_{k  \in \mathbb{N}} c\_k.

입력

The first line contains two positive integers nn and mm (1n100,000,1m250,000)(1 \leq n \leq 100\\,000, 1 \leq m \leq 250\\,000) representing the number of nodes and the number of edges, respectively. The nodes are numbered from 11 to nn. Note that these are \textbf{not} the labels of the nodes.

The second line contains nn integers comprising a permutation of the first nn positive integers, where the ii-th number in the line represents the initial label of node ii.

Each of the next mm lines contains two integers. The ii-th of these lines contains two distinct integers u_iu\_i and v_iv\_i (1u_i,v_in)(1 \leq u\_i, v\_i \leq n), which means u_i,v_iE\\{u\_i, v\_i\\} \in E.

The input will be set in a way such that there are no self-loops, parallel edges, or nodes with a degree of zero.

출력

Print the maximum value of c_kc\_k over all positive integers kk.