자바스크립트 끄적끄적
[백준] 자바스크립트 입력을 받고 또 여려 개 받아야 할 경우 탬플릿
코딩질문자
2024. 12. 16. 18:55
728x90
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const input = [];
rl.on("line", (line) => {
input.push(line);
}).on("close", () => {
const [m, n, k] = input[0].split(" ").map(Number);
const bigMap = Array.from({ length: m }, () => Array(n).fill(0));
let index = 1;
const stikers = [];
for (let i = 0; i < k; i++) {
const [x, y] = input[index++].split(" ").map(Number);
const stiker = [];
for (let j = 0; j < x; j++) {
stiker.push(input[index++].split(" ").map(Number));
}
const indices = [];
for (let row = 0; row < x; row++) {
for (let col = 0; col < y; col++) {
if (stiker[row][col] === 1) {
indices.push([row, col]);
}
}
}
stikers.push({
mapSize: [x, y],
indices,
});
}
});
index를 이용해서 받고 있는 모습
728x90