#include using namespace std; const int MAX_N = 1e5+2; int n,m,s,t; int u0,v0; vector p; vector dist; vector< vector > adj; void bfs() { priority_queue< pair > > pq; /// y , x , v pq.push({0,{p[s],s}}); while(!pq.empty()) { pair > tmp = pq.top(); pq.pop(); if(dist[tmp.second.second] > tmp.first) continue; dist[tmp.second.second] = tmp.first; for(auto x : adj[tmp.second.second]) { if(p[x] < tmp.second.first && dist[x] < dist[tmp.second.second]+1) { pq.push({tmp.first+1,{p[x],x}}); } else if(p[x] >= tmp.second.first && dist[x] < dist[tmp.second.second]) { pq.push({tmp.first,{tmp.second.first,x}}); } } } cout<>n>>m>>s>>t; adj = vector< vector >(n+1); dist = vector(n+1,0); p = vector(n+1,0); for(int i=1; i<=n; i++) { cin>>p[i]; } for(int i=0; i>u0>>v0; adj[u0].push_back(v0); adj[v0].push_back(u0); } bfs(); }