PROBLEM LINK(s): Statement
//ltc.groverkss (Kunwar Shaanjeet Singh Grover) | |
//IIIT Hyderabad | |
#include <iostream> | |
#include <iterator> | |
#include <cstdlib> | |
#include <algorithm> | |
#include <stack> | |
#include <deque> | |
#include <queue> | |
#include <vector> | |
#include <utility> | |
using namespace std; | |
#define ll long long | |
#define ld long double | |
typedef pair<ll,ll> ii; | |
typedef vector<ll> vi; // Vector of long long | |
typedef vector<vi> vvi; // Vector of vi | |
typedef vector<ii> vii; // Vector of pairs | |
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value) | |
#define ff first // For pairs | |
#define ss second // For pairs | |
#define pb push_back // Pushback to vector | |
#define mp make_pair // Makes pairs to be stored as pair | |
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting | |
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key() | |
// order_of_key returns number of elements less that parameter. If element exists, that order is its index | |
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> | |
#define MAX (ll)(1e5 + 10) | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(false); | |
cin.tie(NULL); | |
ll n, m; | |
cin >> n >> m; | |
ll col[n]; | |
vvi camp(MAX); | |
for (int i = 0; i < n; i++) | |
cin >> col[i], col[i]--, camp[col[i]].pb(col[i]); | |
for (int i = 0; i < m; i++) | |
{ | |
ll x, y; | |
cin >> x >> y; | |
x--, y--; | |
camp[col[x]].pb(col[y]); | |
camp[col[y]].pb(col[x]); | |
} | |
ll maxi = -1, id = -1; | |
for (int i = 0; i < MAX; i++) | |
{ | |
sort(all(camp[i])); | |
auto it = unique(all(camp[i])); | |
ll a = it - camp[i].begin(); | |
if (a > maxi) | |
maxi = a, id = i; | |
} | |
cout << id + 1 << "\n"; | |
} |