rt,不知道错哪儿
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m, x, y, ans, l;
vector<int> a[1010];
bool f[1010];
bool check(int x){
if (x == y || f[x]){
return 0;
}
if (x == l){
return 1;
}
f[x] = 1;
for (int i = 0; i < a[x].size(); i++){
if (!check(a[x][i])){
return 0;
}
}
return 1;
}
int main(){
cin >> n >> m;
for (int i = 0; i < m; i++){
cin >> x >> y;
a[x].push_back(y), a[y].push_back(x);
}
cin >> x >> y;
if (check(x)){
cout << -1;
return 0;
}
for (int i = 1; i <= n; i++){
if (i == x || i == y){
continue;
}
fill(f, f + n + 1, 0);
l = i;
if (check(x)){
ans++;
}
}
cout << ans;
return 0;
}