結果

問題 No.1805 Approaching Many Typhoon
ユーザー matcharate12
提出日時 2022-01-10 22:48:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 174,420 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 14:59:09
合計ジャッジ時間 2,478 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	}
	queue<int> Q;
	Q.push(s); seen[s] = 1;
	while(Q.size()){
		int state = Q.front(); Q.pop();
		for(int ss : G[state]){
			if(seen[ss]) continue;
			Q.push(ss);
			seen[ss] = 1;
		}
	}
	cout << (seen[g] ? "Yes" : "No");
}
0