CF246D.Colorful Graph

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You've got an undirected graph, consisting of nn vertices and mm edges. We will consider the graph's vertices numbered with integers from 1 to nn . Each vertex of the graph has a color. The color of the ii -th vertex is an integer cic_{i} .

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

Your task is to find such color kk , which makes the cardinality of set Q(k)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 kk , that the graph has at least one vertex with such color.

输入格式

The first line contains two space-separated integers n,mn,m (1<=n,m<=105)(1<=n,m<=10^{5}) — the number of vertices end edges of the graph, correspondingly. The second line contains a sequence of integers c1,c2,...,cnc_{1},c_{2},...,c_{n} (1<=ci<=105)(1<=c_{i}<=10^{5}) — the colors of the graph vertices. The numbers on the line are separated by spaces.

Next mm lines contain the description of the edges: the ii -th line contains two space-separated integers ai,bia_{i},b_{i} (1<=ai,bi<=n; aibi)(1<=a_{i},b_{i}<=n; a_{i}≠b_{i}) — the numbers of the vertices, connected by the ii -th edge.

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

输出格式

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.

输入输出样例

  • 输入#1

    6 6
    1 1 2 3 5 8
    1 2
    3 2
    1 4
    4 3
    4 5
    4 6
    

    输出#1

    3
    
  • 输入#2

    5 6
    4 2 5 2 4
    1 2
    2 3
    3 1
    5 3
    5 4
    3 4
    

    输出#2

    2
    
首页