結果

問題 No.323 yuki国
ユーザー ikdikd
提出日時 2017-11-15 12:32:45
言語 D
(dmd 2.107.1)
結果
RE  
実行時間 -
コード長 1,071 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 94,992 KB
実行使用メモリ 35,756 KB
最終ジャッジ日時 2023-09-03 16:55:02
合計ジャッジ時間 7,105 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
4,376 KB
testcase_08 RE -
testcase_09 AC 155 ms
21,588 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 149 ms
21,524 KB
testcase_16 RE -
testcase_17 AC 161 ms
35,756 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 165 ms
21,660 KB
testcase_25 AC 164 ms
21,552 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 165 ms
21,636 KB
testcase_29 AC 172 ms
21,588 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 1 ms
4,376 KB
testcase_36 RE -
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[][][](1100, 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