Codeforces Round 151 (Div. 2)
D
Colorful Graph
Codeforces
1600
原题
← CE →
翻译中…

You've got an undirected graph, consisting of $*n*$ vertices and $*m*$ edges. We will consider the graph's vertices numbered with integers from 1 to $*n*$. Each vertex of the graph has a color. The color of the $*i*$-th vertex is an integer $*c*_{*i*}$.

翻译中…

Let's consider all vertices of the graph, that are painted some color $*k*$. Let's denote a set of such as $*V*(*k*)$. Let's denote the value of the neighbouring color diversity for color $*k*$ as the cardinality of the set $*Q*(*k*) = {*c*_{*u*} :  *c*_{*u*} ≠ *k*$ and there is vertex $*v*$ belonging to set $*V*(*k*)$ such that nodes $*v*$ and $*u*$ are connected by an edge of the graph$}$.

翻译中…

Your task is to find such color $*k*$, which makes the cardinality of set $*Q*(*k*)$ maximum. In other words, you want to find the color that has the most diverse neighbours. Please note, that you want to find such color $*k*$, that the graph has at least one vertex with such color.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*n*, *m*$ $(1 ≤ *n*, *m* ≤ 10^{5})$ — the number of vertices end edges of the graph, correspondingly. The second line contains a sequence of integers $*c*_{1}, *c*_{2}, ..., *c*_{*n*}$ $(1 ≤ *c*_{*i*} ≤ 10^{5})$ — the colors of the graph vertices. The numbers on the line are separated by spaces.

翻译中…

Next $*m*$ lines contain the description of the edges: the $*i*$-th line contains two space-separated integers $*a*_{*i*}, *b*_{*i*}$ $(1 ≤ *a*_{*i*}, *b*_{*i*} ≤ *n*; *a*_{*i*} ≠ *b*_{*i*})$ — the numbers of the vertices, connected by the $*i*$-th edge.

翻译中…

It is guaranteed that the given graph has no self-loops or multiple edges.

翻译中…

Output

翻译中…

Print the number of the color which has the set of neighbours with the maximum cardinality. It there are multiple optimal colors, print the color with the minimum number. Please note, that you want to find such color, that the graph has at least one vertex with such color.

翻译中…

样例

Input #1
6 6
1 1 2 3 5 8
1 2
3 2
1 4
4 3
4 5
4 6
Output #1
3
InputCopy OutputCopy
Input #2
5 6
4 2 5 2 4
1 2
2 3
3 1
5 3
5 4
3 4
Output #2
2
InputCopy OutputCopy
题目信息
题号
246D
时间限制
2 s
内存限制
256 MB
标签
暴力
DFS 及类似
图论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。