結果

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

ソースコード

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