結果
問題 | No.1805 Approaching Many Typhoon |
ユーザー |
![]() |
提出日時 | 2022-01-15 19:07:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,002 bytes |
コンパイル時間 | 533 ms |
コンパイル使用メモリ | 58,304 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 22:12:33 |
合計ジャッジ時間 | 1,718 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
/* -*- coding: utf-8 -*-** 1805.cc: No.1805 Approaching Many Typhoon - yukicoder*/#include<cstdio>#include<vector>#include<queue>#include<algorithm>using namespace std;/* constant */const int MAX_N = 2000;/* typedef */typedef vector<int> vi;typedef queue<int> qi;/* global variables */vi nbrs[MAX_N];bool ds[MAX_N], fs[MAX_N];/* subroutines *//* main */int main() {int n, m, st, gl;scanf("%d%d%d%d", &n, &m, &st, &gl);st--, gl--;for (int i = 0; i < m; i++) {int u, v;scanf("%d%d", &u, &v);u--, v--;nbrs[u].push_back(v);nbrs[v].push_back(u);}int un;scanf("%d", &un);for (int i = 0; i < un; i++) {int ii;scanf("%d", &ii), ii--;fs[ii] = true;}ds[st] = true;qi q;q.push(st);while (! q.empty()) {int u = q.front(); q.pop();for (auto v: nbrs[u])if (! ds[v] && ! fs[v]) {ds[v] = true;q.push(v);}}if (ds[gl]) puts("Yes");else puts("No");return 0;}