結果
問題 | No.1805 Approaching Many Typhoon |
ユーザー |
![]() |
提出日時 | 2023-04-01 18:32:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 989 bytes |
コンパイル時間 | 946 ms |
コンパイル使用メモリ | 88,140 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 11:11:44 |
合計ジャッジ時間 | 2,192 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include<iostream>#include<vector>#include<set>#include<queue>using namespace std;int main() {int n, m, s, g;cin >> n >> m >> s >> g;s--; g--;vector<vector<int>> gr(n);for (int i = 0; i < m; i++) {int f, t;cin >> f >> t;f--; t--;gr[f].push_back(t);gr[t].push_back(f);}int u;cin >> u;set<int> I;for (int i = 0; i < u; i++) {int j;cin >> j;j--;I.insert(j);}vector<bool> island(n, false);island[s] = true;queue<int> check;check.push(s);while(!check.empty()) {int c = check.front();for (int i = 0; i < gr[c].size(); i++) {if (island[gr[c][i]] == false && !I.count(gr[c][i])) {island[gr[c][i]] = true;check.push(gr[c][i]);}}check.pop();}if (island[g]) cout << "Yes" << endl;else cout << "No" << endl;return 0;}