結果

問題 No.323 yuki国
ユーザー nebukuro09nebukuro09
提出日時 2016-11-04 00:54:49
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,479 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 101,180 KB
実行使用メモリ 94,188 KB
最終ジャッジ日時 2023-09-02 22:44:15
合計ジャッジ時間 8,157 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;

void main() {
  auto input = readln.split.map!(to!int);
  int H = input[0];
  int W = input[1];
  input = readln.split.map!(to!int);
  int A = input[0];
  int Si = input[1];
  int Sj = input[2];
  input = readln.split.map!(to!int);
  int C = input[0];
  int Gi = input[1];
  int Gj = input[2];
  string[] B = new string[](H);
  foreach (i; iota(H))
    B[i] = readln.chomp;

  DList!(Tuple!(int, int, int)) queue;
  queue.insert(tuple(Si, Sj, A));
  int i, j, s;
  Tuple!(int, int, int) node;
  bool[long] visited;
  int[4] dx = [0, 0, 1, -1];
  int[4] dy = [1, -1, 0, 0];
  while (!queue.empty()) {
    node = queue.front;
    queue.removeFront();
    i = node[0];
    j = node[1];
    s = node[2];
    if (i == Gi && j == Gj && s == C) {
      writeln("YES");
      return;
    }
    if (i*100000000.to!long+j*1000000+s*10000 in visited)
      continue;
    visited[i*100000000.to!long+j*1000000+s*10000] = true;

    foreach (k; iota(4)) {
      int ni = i + dx[k];
      int nj = j + dy[k];
      if (ni < 0 || ni >= H || nj < 0 || nj >= W)
        continue;
      int ns = B[ni][nj] == '*' ? s + 1 : s - 1;
      if (ns <= 0 || ns > 10000 || ni*100000000.to!long+nj*1000000+ns*10000 in visited)
        continue;
      queue.insert(tuple(ni, nj, ns));
    }
  }

  writeln("NO");
}
0