PS/백준
백준 / 4195번 / 친구 네트워크 / JS
https://www.acmicpc.net/problem/4195 풀이const fs = require('fs');const filePath = process.platform === 'linux' ? 0 : './input.txt';const input = fs.readFileSync(filePath).toString().trim().split('\n');const T = +input.shift();function* idGenerator() { let id = 0; while (true) { yield id++; }}class UnionFind { constructor() { this.parent = []; this.count = []; this.nameMap = new Ma..
백준 / 16935번 / 배열 돌리기 3
풀이const fs = require('fs');const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';// const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt';const input = fs.readFileSync(filePath).toString().trim().split('\n');const [N, M, R] = input.shift().split(' ').map(Number);const opList = input.pop().split(' ').map(Number);let arr = input.map((row) => row.spli..
백준 / 3190번 / 뱀 / JS
풀이const fs = require('fs');const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';// const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt';const input = fs.readFileSync(filePath).toString().trim().split('\n');let N, K, L;const snakeDirInfo = [];let snakeDirInfoIndex = 0;const APPLE = 1;const EMPTY = 0;const SNAKE = -1;let board;// 상, 우, 하, 좌const dr..
백준 / 투 포인터 / 22862번 / 가장 긴 짝수 연속한 부분 수열 (large) / JS
문제 간단설명길이가 N인 수열 S가 있다. 수열 S는 1이상 정수로 이루어져 있는데,최대 K개의 정수를 삭제할 수 있다. 최대 K개 삭제한 수열에서,짝수로 이루어져 있는 연속한 부분 수열 중,가장 긴 길이를 구하면 된다. 제한 사항1 1 1 성공 코드const fs = require('fs');const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt';// const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt';const input = fs .readFileSync(filePath) .toString() .trim() .split(..
백준 / 수학 / 11444번 / 피보나치 수 6 / JS
문제 간단설명n이 주어졌을 때, n번째 피보나치 수를 출력하면 된다. 제한 사항 n은 1,000,000,000,000,000,000보다 작거나 같은 자연수이다. 성공 코드const fs = require('fs');const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt';// const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt';const input = fs .readFileSync(filePath) .toString() .trim() .split('\n') .map((el) => el.trim());const n = BigI..
백준 / 그래프 / 2206번 / 벽 부수고 이동하기 / JS
문제 간단설명 N×M 크기의 맵이 주어집니다맵의 각 칸은 0(이동 가능) 또는 1(벽)입니다(1,1)에서 (N,M)까지 이동하려고 합니다벽을 한 번만 부술 수 있는 능력이 있습니다목표는 최단 경로의 길이를 찾는 것입니다 제한 사항1 1 (1, 1)과 (N, M)은 항상 0이다.실패 코드 (시간 초과)const fs = require('fs');const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt';// const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt';const input = fs .readFileSync(filePath) .t..