結果

問題 No.92 逃走経路
ユーザー te-shte-sh
提出日時 2017-01-27 13:55:05
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 100,584 KB
実行使用メモリ 5,212 KB
最終ジャッジ日時 2023-09-03 00:55:45
合計ジャッジ時間 1,942 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 16 ms
4,376 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1], k = rd1[2];

  int[int][int] buf;
  foreach (_; m.iota) {
    auto rd2 = readln.split.to!(int[]), a = rd2[0] - 1, b = rd2[1] - 1, c = rd2[2];
    buf[c][a] = b;
    buf[c][b] = a;
  }

  auto di = readln.split.to!(int[]);

  auto ei = buf[di.front].keys;
  foreach (d; di.drop(1)) {
    int[] fi;
    foreach (e; ei)
      if (e in buf[d]) fi ~= buf[d][e];
    ei = fi;
  }

  writeln(ei.length);
  writeln(ei.sort().map!"a + 1".map!(to!string).join(" "));
}
0