結果
| 問題 | 
                            No.1805 Approaching Many Typhoon
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-10 18:28:25 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 702 bytes | 
| コンパイル時間 | 1,821 ms | 
| コンパイル使用メモリ | 174,356 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-15 14:58:26 | 
| 合計ジャッジ時間 | 3,112 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 35 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define all(A) (A).begin(),(A).end()
#define MOD 1000000007
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main() {
	int n,m,s,g; cin >> n >> m >> s >> g;
	s--; g--;
	Graph G(n);
	rep(i,0,m){
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> seen(n,0);
	int u; cin >> u;
	rep(i,0,u){
		int c; cin >> c;
		c--;
		seen[c] = 1;
	}
	stack<int> S;
	S.push(s); seen[s] = 1;
	while(S.size()){
		int state = S.top(); S.pop();
		for(int ss : G[state]){
			if(seen[ss]) continue;
			S.push(ss);
			seen[ss] = 1;
		}
	}
	cout << (seen[g] ? "Yes" : "No");
}