結果

問題 No.92 逃走経路
ユーザー te-sh
提出日時 2017-01-27 14:04:41
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 636 bytes
コンパイル時間 979 ms
コンパイル使用メモリ 110,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 06:38:24
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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.sort().uniq();
  foreach (d; di.drop(1)) {
    int[] fi;
    foreach (e; ei)
      if (e in buf[d]) fi ~= buf[d][e];
    ei = fi.sort().uniq();
  }

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