結果
問題 |
No.1805 Approaching Many Typhoon
|
ユーザー |
|
提出日時 | 2022-01-10 19:49:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 721 bytes |
コンパイル時間 | 1,622 ms |
コンパイル使用メモリ | 175,564 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 14:58:28 |
合計ジャッジ時間 | 2,571 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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(void){ int n,m,s,g; cin >> n >> m >> s >> g; s--; g--; vector<vector<int>> G(n); rep(i,0,m){ int f,t; cin >> f >> t; f--; t--; G[f].push_back(t); G[t].push_back(f); } stack<int> S; vector<int> seen(n,0); int w; cin >> w; rep(i,0,w){ int a; cin >> a; a--; seen[a] = 1; } S.push(s); seen[s] = 1; while(S.size()){ int state = S.top(); S.pop(); for(int s2 : G[state]){ if(seen[s2]) continue; S.push(s2); seen[s2] = 1; } } cout << (seen[g] ? "Yes" : "No"); }