結果
問題 | No.1805 Approaching Many Typhoon |
ユーザー |
|
提出日時 | 2022-09-25 13:10:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 1,895 ms |
コンパイル使用メモリ | 203,136 KB |
最終ジャッジ日時 | 2025-02-07 14:51:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int N,M;cin>>N>>M;int S,G;cin>>S>>G;--S,--G;vector<vector<int>>A(N);for(int i=0;i<M;i++){int u,v;cin>>u>>v;--u,--v;A[u].push_back(v),A[v].push_back(u);}int U;cin>>U;vector<bool>NG(N);for(int i=0;i<U;i++){int a;cin>>a;NG[a-1]=true;}queue<int>bfs;bfs.push(S);vector<bool>vst(N);vst[S]=true;while(bfs.size()){int v=bfs.front();bfs.pop();if(NG[v])continue;for(int i:A[v]){if(!vst[i]){vst[i]=true;bfs.push(i);}}}cout<<(vst[G]?"Yes\n":"No\n");}