結果

問題 No.1805 Approaching Many Typhoon
ユーザー yansi819
提出日時 2024-04-18 11:02:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 4,309 ms
コンパイル使用メモリ 256,044 KB
最終ジャッジ日時 2025-02-21 03:00:34
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  int n, m; cin >> n >> m;
  int s, g; cin >> s >> g; s--, g--;
  vector<pair<int, int>> ft(m);
  for (int i = 0; i < m; i++) {
    cin >> ft[i].first >> ft[i].second;
    ft[i].first--, ft[i].second--;
  }
  int u; cin >> u;
  set<int> st;
  for (int i = 0; i < u; i++) {
    int k; cin >> k;
    k--;
    st.insert(k);
  }
  dsu uf(n);
  for (int i = 0; i < m; i++) {
    if (st.count(ft[i].first) or st.count(ft[i].second)) continue;
    uf.merge(ft[i].first, ft[i].second);
  }
  cout << (uf.same(s, g) ? "Yes": "No") << endl;
  return 0;
}
0