#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,m,s,d,a,b;
cin >> n >> m >> s >> d >> a >> b;
vector<vector<int> > graph(n+1,vector<int>());
for(int i = 0; i < m; i++) {
int x,y;
cin >> x >> y;
graph[x].push_back(y);
graph[y].push_back(x);
}
vector<bool> wass(n+1,false);
vector<int> dists(n+1,0);
vector<bool> wasd(n+1,false);
vector<int> distd(n+1,0);
vector<bool> wasa(n+1,false);
vector<int> dista(n+1,0);
vector<bool> wasb(n+1,false);
vector<int> distb(n+1,0);
wass[s] = true;
queue<int> q;
q.push(s);
while(!q.empty()) {
int v = q.front();
q.pop();
for(int u : graph[v]) {
if(!wass[u]) {
wass[u] = true;
q.push(u);
dists[u] = dists[v]+1;
}
}
}
wasd[d] = true;
q.push(d);
while(!q.empty()) {
int v = q.front();
q.pop();
for(int u : graph[v]) {
if(!wasd[u]) {
wasd[u] = true;
q.push(u);
distd[u] = distd[v]+1;
}
}
}
wasa[a] = true;
q.push(a);
while(!q.empty()) {
int v = q.front();
q.pop();
for(int u : graph[v]) {
if(!wasa[u]) {
wasa[u] = true;
q.push(u);
dista[u] = dista[v]+1;
}
}
}
wasb[b] = true;
q.push(b);
while(!q.empty()) {
int v = q.front();
q.pop();
for(int u : graph[v]) {
if(!wasb[u]) {
wasb[u] = true;
q.push(u);
distb[u] = distb[v]+1;
}
}
}
if(dists[a] == dists[b] && distd[a] == distd[b]) {
int mxdistd = -1;
int mxdists = -1;
for(int i = 1; i <= n; i++) {
if(dista[i] == distb[i]) {
if(dista[i]+distd[i] == distd[a]) {
mxdistd = mx(mxdistd,dista[i]);
}
if(dista[i]+dists[i] == dists[a]) {
mxdists = mx(mxdists,dista[i]);
}
}
}
if(mxdists > mxdistd) {
cout << max(min(distd[a]-dists[a],distd[b]-dists[b])-1,-1);
} else {
cout << max(min(distd[a]-dists[a],distd[b]-dists[b]),-1);
}
} else {
cout << max(min(distd[a]-dists[a],distd[b]-dists[b]),-1);
}
return 0;
}
Compilation message
007.cpp: In function 'int main()':
007.cpp:85:31: error: 'mx' was not declared in this scope
mxdistd = mx(mxdistd,dista[i]);
^~
007.cpp:85:31: note: suggested alternative: 'm'
mxdistd = mx(mxdistd,dista[i]);
^~
m
007.cpp:88:31: error: 'mx' was not declared in this scope
mxdists = mx(mxdists,dista[i]);
^~
007.cpp:88:31: note: suggested alternative: 'm'
mxdists = mx(mxdists,dista[i]);
^~
m