結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2023-01-13 21:51:52 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 311 ms / 5,000 ms |
コード長 | 1,013 bytes |
コンパイル時間 | 2,189 ms |
コンパイル使用メモリ | 209,736 KB |
実行使用メモリ | 32,100 KB |
最終ジャッジ日時 | 2024-06-22 17:17:39 |
合計ジャッジ時間 | 6,166 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
import std; enum int L = 2000; struct Snowball { int x, y, size; } void main() { int H, W, A, Si, Sj, B, Gi, Gj; readf("%d %d\n%d %d %d\n%d %d %d\n", H, W, A, Si, Sj, B, Gi, Gj); auto M = new string[](H); foreach (i; 0 .. H) readf("%s\n", M[i]); int[] dx = [-1, 0, 1, 0], dy = [0, 1, 0, -1]; auto seen = new bool[][][](H, W, L); seen[Si][Sj][A] = true; Snowball[] que; que ~= Snowball(Si, Sj, A); while (!que.empty) { if (seen[Gi][Gj][B]) break; auto f = que.front; que.popFront; static foreach (i; 0 .. 4) {{ int nx = f.x + dx[i], ny = f.y + dy[i]; if (0 <= nx && nx < H && 0 <= ny && ny < W) { int s = f.size + (M[nx][ny] == '*' ? 1 : -1); if (0 < s && s < L && !seen[nx][ny][s]) { seen[nx][ny][s] = true; que ~= Snowball(nx, ny, s); } } }} } writeln(seen[Gi][Gj][B] ? "Yes" : "No"); }