int N, M; while (cin >> N >> M) { vector<int> d[N]; queue<int> q; bool check[800] = {false}; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; d[a].push_back(b); } // 將能走的路徑都設為 true int A, B; cin >> A >> B; A--; B--; q.push(A); check[A] = true; while (!q.empty()) { int temp = q.front(); q.pop(); for (auto &i : d[temp]) { if (!check[i]) { check[i] = true; q.push(i); } } } // 訪問 B 點是否能走到 if (check[B]) { cout << "Yes!!!\n"; } else { cout << "No!!!\n"; } } return0; }