记忆化搜索
#include <bits/stdc++.h>
using namespace std;
const int N = 510;
vector<int> v[N];
bool vis[N];
int num[N];
int n, m, s, d;
int dfs(int x)
{
vis[x] = true;
if (num[x]) return num[x];
int res = 0;
for (auto c : v[x]) res += dfs(c);
return num[x] = res;
}
int main()
{
cin >> n >> m;
while (m--)
{
int a, b;
scanf("%d%d", &a, &b);
v[a].push_back(b);
}
cin >> s >> d;
num[d] = 1;
cout << dfs(s) << ' ';
bool f = true;
for (int i = 1; i <= n; i++)
if (!num[i] && vis[i]) f = false;
cout << (f ? "Yes" : "No");
return 0;
}