結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-31 23:56:44 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,124 bytes |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 6,948 KB |
| 実行使用メモリ | 464,688 KB |
| 最終ジャッジ日時 | 2024-10-31 23:56:51 |
| 合計ジャッジ時間 | 6,788 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 27 |
ソースコード
function Main(INPUT){
const input=INPUT.split("\n");
const [N,M,K]=input[0].split(" ").map(_=>parseInt(_));
const start=input[1].split(" ").map(_=>parseInt(_));
const path=Array(N).fill().map(_=>[]);
for(let i=0;i<M;i++){
let [u,v]=input[i+2].split(" ").map(_=>parseInt(_));
u--;
v--;
path[u].push(v);
path[v].push(u);
}
const reach=Array(N).fill().map(_=>Array(N).fill().map(_=>[]));
for(let i=0;i<K;i++){
let s=start[i];
s--;
let ss=new Set([s])
let t=new Set([[ss, s]]);
let q=[[ss,s]];
reach[s][0].push(i);
while(q.length>0){
let [v,now]=q.pop();
for(let x of path[now]){
if(v.has(x)) continue;
let u=new Set([...v, x]);
if(!t.has([u,x])){
if(!reach[x][u.size-1].includes(i)){
reach[x][u.size-1].push(i);
}
t.add([u,x]);
q.push([u,x]);
}
}
}
}
let ok=false;
for(let i=0;i<N;i++){
for(let j=0;j<N;j++){
if(reach[i][j].length==K) ok=true;
}
}
console.log(ok?"Yes":"No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));