#include #include "bits/stdc++.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; const int INF = 1e8; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) using namespace std; typedef pair P; vector G[1001]; ll v[1005]; bool visited[1001]; ll kadomatu[3]; string to_string(ll x) { stringstream ss; ss << x; return ss.str(); } int cti(char a) { return a - '0'; } bool judge = false; void dfs(int n, int s) { if (n == 2) { kadomatu[2] =v[s]; if (kadomatu[0]kadomatu[2] && kadomatu[0] != kadomatu[2] || kadomatu[0]>kadomatu[1] && kadomatu[1]> n >> m; int tmp; for (int i = 1; i <= n; i++) { cin >> tmp; v[i] = tmp; } int s, t; for (int i = 0; i < m; i++) { cin >> s >> t; G[s].push_back(t); G[t].push_back(s); } for (int i = 1; i <= n; i++) { visited[i] = true; kadomatu[0] = v[i]; dfs(0, i); if (judge) { cout << "YES" << endl; return 0; } visited[i] = false; } cout << "NO" << endl; return 0; }