結果
問題 | No.1805 Approaching Many Typhoon |
ユーザー |
![]() |
提出日時 | 2022-01-13 06:40:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 611 bytes |
コンパイル時間 | 4,540 ms |
コンパイル使用メモリ | 251,496 KB |
最終ジャッジ日時 | 2025-01-27 10:43:40 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using mint = modint998244353;using namespace std;#define rep(i,n) for(int i=0;i<(n);i++)#define Inf 1000000001int main(){int N,M;cin>>N>>M;int s,g;cin>>s>>g;s--;g--;vector<int> f(M),t(M);rep(i,M){cin>>f[i]>>t[i];f[i]--;t[i]--;}vector<bool> ng(N,false);int U;cin>>U;rep(_,U){int x;cin>>x;ng[x-1] = true;}dsu D(N);rep(i,M){if(ng[f[i]] || ng[t[i]])continue;D.merge(f[i],t[i]);}if(D.same(s,g))cout<<"Yes"<<endl;else cout<<"No"<<endl;return 0;}