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
'자바스크립트 끄적끄적' 카테고리의 다른 글
자바스크립트는 왜 그 모양일까? (1) | 2023.12.20 |
---|---|
html 에서 html 로 데이터 보내기 with 바닐라 자바스크립트 (1) | 2023.12.08 |
커링 함수 (0) | 2023.11.30 |
[JSX] 자바스크립트 꿀팁 (0) | 2023.05.26 |
타입스크립트 설명 (0) | 2023.04.17 |