結果
問題 | No.92 逃走経路 |
ユーザー |
|
提出日時 | 2016-08-30 14:22:39 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 1,067 ms |
コンパイル使用メモリ | 125,312 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 03:51:14 |
合計ジャッジ時間 | 1,792 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
import std.algorithm, std.array, std.container, std.range;import std.string, std.conv;import std.math, std.bigint, std.bitmanip, std.random;import std.stdio, std.typecons;alias Tuple!(int, "n1", int, "n2") side;void main(){auto rd1 = readln.split.map!(to!int);auto n = rd1[0], m = rd1[1], k = rd1[2];side[][int] si;foreach (_; 0..m) {auto rd2 = readln.split.map!(to!int);si[rd2[2]] ~= side(rd2[0] - 1, rd2[1] - 1);}auto di = readln.split.map!(to!int);auto cands = BitArray([]);cands.length = n;foreach (s; si[di[0]]) {cands[s.n1] = true;cands[s.n2] = true;}foreach (i; 1..k) {auto next = BitArray([]);next.length = n;foreach (s; si[di[i]]) {if (cands[s.n1])next[s.n2] = true;if (cands[s.n2])next[s.n1] = true;}cands = next;}auto r = cands.bitsSet.array;writeln(r.length);writeln(r.map!(x => x + 1).map!(to!string).join(' '));}