結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2017-11-15 12:32:00 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 480 ms / 5,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 726 ms |
コンパイル使用メモリ | 109,272 KB |
実行使用メモリ | 71,428 KB |
最終ジャッジ日時 | 2024-06-12 22:32:27 |
合計ジャッジ時間 | 6,629 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
void main(){import std.stdio, std.string, std.conv, std.algorithm;import std.container, std.typecons;int h, w; rd(h, w);int a, si, sj; rd(a, si, sj);int b, gi, gj; rd(b, gi, gj);auto mat=new char[][](h, w);foreach(i; 0..h) mat[i]=readln.chomp.to!(char[]);alias T=Tuple!(int, "sz", int, "i", int, "j");auto dir=[[0, 1], [0, -1], [1, 0], [-1, 0]];auto vis=new bool[][][](2000, h, w);auto Q=new DList!(T)(T(a, si, sj));while(!Q.empty){auto cur=Q.front; Q.removeFront;if(cur.sz==b && cur.i==gi && cur.j==gj){writeln("Yes"); return;}foreach(d; dir){auto ni=cur.i+d[0], nj=cur.j+d[1];if(ni<0 || nj<0 || ni>=h || nj>=w) continue;auto nsz=cur.sz+(mat[ni][nj]=='*'?1:-1);if(nsz>0 && nsz<2000 && !vis[nsz][ni][nj]){vis[nsz][ni][nj]=true;Q.insertFront(T(nsz, ni, nj));}}}writeln("No");}void rd(T...)(ref T x){import std.stdio, std.string, std.conv;auto l=readln.split;assert(l.length==x.length);foreach(i, ref e; x){e=l[i].to!(typeof(e));}}