結果

問題 No.323 yuki国
ユーザー ikdikd
提出日時 2017-11-15 12:32:00
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 456 ms / 5,000 ms
コード長 1,071 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 94,912 KB
実行使用メモリ 71,940 KB
最終ジャッジ日時 2023-09-03 16:54:55
合計ジャッジ時間 6,690 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 297 ms
35,396 KB
testcase_09 AC 156 ms
21,556 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 151 ms
21,556 KB
testcase_14 AC 271 ms
35,396 KB
testcase_15 AC 155 ms
21,540 KB
testcase_16 AC 279 ms
21,540 KB
testcase_17 AC 163 ms
44,240 KB
testcase_18 AC 115 ms
21,524 KB
testcase_19 AC 214 ms
48,052 KB
testcase_20 AC 456 ms
71,652 KB
testcase_21 AC 422 ms
70,932 KB
testcase_22 AC 66 ms
21,512 KB
testcase_23 AC 442 ms
71,940 KB
testcase_24 AC 169 ms
21,556 KB
testcase_25 AC 172 ms
21,604 KB
testcase_26 AC 324 ms
21,536 KB
testcase_27 AC 332 ms
21,580 KB
testcase_28 AC 172 ms
21,620 KB
testcase_29 AC 180 ms
21,584 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 4 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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));
  }
}
0