結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-31 17:22:06 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 993 bytes |
| コンパイル時間 | 379 ms |
| コンパイル使用メモリ | 7,076 KB |
| 実行使用メモリ | 41,712 KB |
| 最終ジャッジ日時 | 2024-10-31 17:22:11 |
| 合計ジャッジ時間 | 4,309 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 8 |
ソースコード
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(_=>[[],[]]);
for(let i=0;i<K;i++){
let s=start[i];
s--;
const check=Array(N).fill().map(_=>[false,false]);
check[s][0]=true;
let q=[[s,0]];
while(q.length>0){
let [now,b]=q.pop();
reach[now][b].push(i);
for(let x of path[now]){
if(!check[x][(b+1)%2]){
check[x][(b+1)%2]=true;
q.push([x,(b+1)%2]);
}
}
}
}
let ok=false;
for(let i=0;i<N;i++){
if(reach[i][0].length==K) ok=true;
if(reach[i][1].length==K) ok=true;
}
console.log(ok?"Yes":"No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));