Submission #66797267
Source Code Expand
import * as fs from 'fs';
// 標準入力からデータを読み取る
const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
// 最初の行から N と M を取得
const [N, M] = input[0].split(' ').map(Number);
// 隣接リスト:各頂点に対して接続されている頂点の配列
const graph: number[][] = Array.from({ length: N + 1 }, () => []);
// 入力された M 本の辺を処理
for (let i = 1; i <= M; i++) {
const [a, b] = input[i].split(' ').map(Number);
graph[a].push(b);
graph[b].push(a); // 無向グラフなので両方に追加
}
// 各頂点について、隣接頂点を出力
for (let i = 1; i <= N; i++) {
console.log(`${i}: {${graph[i].join(', ')}}`);
}
Submission Info
| Submission Time | |
|---|---|
| Task | A61 - Adjacent Vertices |
| User | myoshizumi |
| Language | TypeScript 5.1 (Node.js 18.16.1) |
| Score | 1000 |
| Code Size | 742 Byte |
| Status | AC |
| Exec Time | 530 ms |
| Memory | 111172 KiB |
Compile Error
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample00.txt, sample01.txt |
| All | 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, sample00.txt, sample01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00.txt | AC | 46 ms | 44756 KiB |
| 01.txt | AC | 44 ms | 44500 KiB |
| 02.txt | AC | 133 ms | 74948 KiB |
| 03.txt | AC | 137 ms | 61236 KiB |
| 04.txt | AC | 410 ms | 99800 KiB |
| 05.txt | AC | 285 ms | 64260 KiB |
| 06.txt | AC | 530 ms | 110760 KiB |
| 07.txt | AC | 528 ms | 111172 KiB |
| sample00.txt | AC | 38 ms | 42896 KiB |
| sample01.txt | AC | 38 ms | 42860 KiB |