結果
問題 |
No.1805 Approaching Many Typhoon
|
ユーザー |
![]() |
提出日時 | 2025-07-09 00:06:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,045 bytes |
コンパイル時間 | 4,159 ms |
コンパイル使用メモリ | 288,516 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-07-09 00:06:34 |
合計ジャッジ時間 | 4,993 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m, s, g; cin >> n >> m >> s >> g; --s, --g; vector Graph(n, vector<int>()); rep(_, m) { int u, v; cin >> u >> v; --u, --v; Graph[u].push_back(v); Graph[v].push_back(u); } set<int> forbidden; { int u; cin >> u; rep(_, u) { int v; cin >> v; --v; forbidden.insert(v); } } constexpr int INF = 1e9; vector<int> dist(n, INF); dist[s] = 0; queue<int> q; q.push(s); while (!q.empty()) { int u = q.front(); q.pop(); for (int v : Graph[u]) { if (forbidden.contains(v)) continue; if (dist[v] > dist[u] + 1) { dist[v] = dist[u] + 1; q.push(v); } } } cout << (dist[g] == INF ? "No" : "Yes") << '\n'; return 0; }