結果
問題 | No.1805 Approaching Many Typhoon |
ユーザー |
![]() |
提出日時 | 2022-10-27 22:19:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 2,116 ms |
コンパイル使用メモリ | 209,904 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 16:32:11 |
合計ジャッジ時間 | 3,280 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
import std;void main() {int N, M, S, G;readf("%d %d\n%d %d\n", N, M, S, G);--S, --G;auto toList = new int[][](N);foreach (_; 0 .. M) {int F, T;readf("%d %d\n", F, T);--F, --T;toList[F] ~= T, toList[T] ~= F;}int U;readf("%d\n", U);auto I = readln.chomp.split.to!(int[]);auto closed = new bool[](N);foreach (i; I) closed[i-1] = true;auto visited = new bool[](N);void f(int x) {visited[x] = true;foreach (t; toList[x]) {if (closed[t] || visited[t]) continue;f(t);}}f(S);writeln(visited[G] ? "Yes" : "No");}