#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> heights(305, 0);
vector<vector<bool>> graph(305, vector<bool>(305, 0));
int n, m;
cin >> n >> m;
int max_val = 0;
for (int i = 1; i <= n; i++)
{
cin >> heights[i];
if (heights[max_val] < heights[i])
{
max_val = i;
}
}
for (int i = 0; i < m; i++)
{
int a, b;
cin >> a >> b;
if (heights[a] > heights[b])
{
graph[a][b] = 1;
}
else if (heights[a] < heights[b])
{
graph[b][a] = 1;
}
}
int bfs_cnt = 0;
vector<bool> visited(305, 0);
queue<int> q;
q.push(max_val);
while(!q.empty())
{
int tmp = q.front();
q.pop();
visited[tmp] = 1;
bfs_cnt++;
for (int i = 1; i <= n; i++)
{
if (graph[tmp][i] && !visited[i])
{
q.push(i);
}
}
}
if (bfs_cnt == n)
{
cout << "Oui, j'ai trouve la solution.\n"
<< max_val;
}
else
{
cout << "Non";
}
}
测评记录