結果

問題 No.92 逃走経路
ユーザー te-shte-sh
提出日時 2017-01-27 14:04:41
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 636 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 101,772 KB
実行使用メモリ 5,952 KB
最終ジャッジ日時 2023-09-03 00:55:50
合計ジャッジ時間 2,264 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,428 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 24 ms
5,920 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 178 ms
4,968 KB
testcase_11 AC 157 ms
4,752 KB
testcase_12 AC 78 ms
5,952 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 19 ms
4,380 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 14 ms
4,380 KB
testcase_18 AC 9 ms
4,384 KB
testcase_19 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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