結果
問題 | No.92 逃走経路 |
ユーザー | jp_ste |
提出日時 | 2020-04-20 14:11:11 |
言語 | JavaScript (node v21.7.1) |
結果 |
AC
|
実行時間 | 362 ms / 5,000 ms |
コード長 | 1,453 bytes |
コンパイル時間 | 79 ms |
コンパイル使用メモリ | 6,940 KB |
実行使用メモリ | 48,000 KB |
最終ジャッジ日時 | 2024-04-21 03:23:21 |
合計ジャッジ時間 | 4,477 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 248 ms
47,104 KB |
testcase_01 | AC | 64 ms
39,168 KB |
testcase_02 | AC | 63 ms
39,168 KB |
testcase_03 | AC | 68 ms
39,168 KB |
testcase_04 | AC | 63 ms
39,424 KB |
testcase_05 | AC | 70 ms
43,392 KB |
testcase_06 | AC | 71 ms
43,520 KB |
testcase_07 | AC | 78 ms
43,392 KB |
testcase_08 | AC | 83 ms
44,800 KB |
testcase_09 | AC | 356 ms
47,616 KB |
testcase_10 | AC | 180 ms
45,568 KB |
testcase_11 | AC | 221 ms
45,952 KB |
testcase_12 | AC | 362 ms
48,000 KB |
testcase_13 | AC | 208 ms
45,824 KB |
testcase_14 | AC | 218 ms
46,080 KB |
testcase_15 | AC | 259 ms
47,104 KB |
testcase_16 | AC | 216 ms
46,592 KB |
testcase_17 | AC | 226 ms
46,848 KB |
testcase_18 | AC | 127 ms
45,056 KB |
testcase_19 | AC | 87 ms
44,416 KB |
ソースコード
function main(input) { input = input.split("\n"); let line = input.shift().split(" "); const n = Number(line[0]); const m = Number(line[1]); const k = Number(line[2]); let mList = new Array(n); for(let i=0; i<n; i++) { mList[i] = new Array(n).fill().map(function(e){ return []; }); } for(let i=0; i<m; i++) { line = input.shift().split(" "); const p1 = Number(line[0]) - 1; const p2 = Number(line[1]) - 1; const cost = Number(line[2]); mList[p1][p2].push(cost); mList[p2][p1].push(cost); } let kList = input.shift().split(" ").map(function(e) { return Number(e); }); let ansSet = new Set(); for(let i=0; i<n; i++) { for(let j=0; j<n; j++) { const index = mList[i][j].indexOf(kList[0]); if(index >= 0) { ansSet.add(j); } } } for(let i=1; i<k; i++) { const nextK = kList[i]; let nextAnsSet = new Set(); ansSet.forEach(function(from) { for(let to=0; to<n; to++) { const index = mList[from][to].indexOf(nextK); if(index >= 0) { nextAnsSet.add(to); } } }); ansSet = nextAnsSet; } const ansList = Array.from(ansSet).sort(function(a, b) { return a - b; }); console.log(ansList.length); let str = ""; ansList.forEach(function(e, i) { if(i > 0) str += " "; str += (e+1); }); console.log(str); } main(require("fs").readFileSync("/dev/stdin", "utf8"));