結果
問題 | No.92 逃走経路 |
ユーザー | jp_ste |
提出日時 | 2020-04-20 07:17:23 |
言語 | JavaScript (node v21.7.1) |
結果 |
AC
|
実行時間 | 376 ms / 5,000 ms |
コード長 | 1,453 bytes |
コンパイル時間 | 41 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 48,128 KB |
最終ジャッジ日時 | 2024-04-21 03:23:17 |
合計ジャッジ時間 | 4,561 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 268 ms
47,360 KB |
testcase_01 | AC | 72 ms
39,040 KB |
testcase_02 | AC | 72 ms
39,168 KB |
testcase_03 | AC | 78 ms
39,040 KB |
testcase_04 | AC | 73 ms
39,168 KB |
testcase_05 | AC | 79 ms
43,392 KB |
testcase_06 | AC | 81 ms
43,648 KB |
testcase_07 | AC | 81 ms
43,392 KB |
testcase_08 | AC | 91 ms
44,928 KB |
testcase_09 | AC | 376 ms
47,744 KB |
testcase_10 | AC | 193 ms
45,440 KB |
testcase_11 | AC | 232 ms
45,952 KB |
testcase_12 | AC | 373 ms
48,128 KB |
testcase_13 | AC | 213 ms
45,696 KB |
testcase_14 | AC | 234 ms
46,080 KB |
testcase_15 | AC | 281 ms
46,976 KB |
testcase_16 | AC | 227 ms
46,720 KB |
testcase_17 | AC | 240 ms
46,592 KB |
testcase_18 | AC | 139 ms
45,184 KB |
testcase_19 | AC | 99 ms
44,288 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"));