그래프 탐색

알고리즘 연습

[알고리즘 연습] 백준 13549 (숨바꼭질 3, 자바스크립트)

문제 13549번: 숨바꼭질 3 수빈이는 동생과 숨바꼭질을 하고 있다. 수빈이는 현재 점 N(0 ≤ N ≤ 100,000)에 있고, 동생은 점 K(0 ≤ K ≤ 100,000)에 있다. 수빈이는 걷거나 순간이동을 할 수 있다. 만약, 수빈이의 위치가 X일 www.acmicpc.net 소스 코드 const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const input = require('fs') .readFileSync(filePath) .toString() .trim() .split('\n'); const [N, K] = input[0].split(' ').map(Number); const MAX_SIZE = 1000..

알고리즘 연습

[알고리즘 연습] 백준 13023 (ABCDE, 자바스크립트)

문제 13023번: ABCDE 문제의 조건에 맞는 A, B, C, D, E가 존재하면 1을 없으면 0을 출력한다. www.acmicpc.net 소스 코드 const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const input = require('fs') .readFileSync(filePath) .toString() .trim() .split('\n'); const [N, M] = input[0].split(' ').map(Number); const graph = []; for (let i = 0; i < N; i++) graph[i] = []; for (let i = 1; i = 5) { flag = true; r..

알고리즘 연습

[알고리즘 연습] 백준 17836 (공주님을 구해라!, 자바스크립트)

문제 17836번: 공주님을 구해라! 용사는 마왕이 숨겨놓은 공주님을 구하기 위해 (N, M) 크기의 성 입구 (1,1)으로 들어왔다. 마왕은 용사가 공주를 찾지 못하도록 성의 여러 군데 마법 벽을 세워놓았다. 용사는 현재의 가지고 있는 www.acmicpc.net 소스 코드 class Queue { constructor() { this.dat = []; this.head = 0; this.tail = 0; } push(item) { this.dat[this.tail++] = item; } pop() { this.head++; } front() { return this.dat[this.head]; } rear() { return this.dat[this.tail - 1]; } isEmpty() { ret..

알고리즘 연습

[알고리즘 연습] 백준 14502 (연구소, 자바스크립트)

문제 14502번: 연구소 인체에 치명적인 바이러스를 연구하던 연구소에서 바이러스가 유출되었다. 다행히 바이러스는 아직 퍼지지 않았고, 바이러스의 확산을 막기 위해서 연구소에 벽을 세우려고 한다. 연구소는 크 www.acmicpc.net 소스 코드 class Queue { constructor() { this.dat = []; this.head = 0; this.tail = 0; } push(item) { this.dat[this.tail++] = item; } pop() { this.head++; } front() { return this.dat[this.head]; } rear() { return this.dat[this.tail - 1]; } isEmpty() { return this.head ==..

알고리즘 연습

[알고리즘 연습] 백준 5547 (일루미네이션, 자바스크립트)

문제 5547번: 일루미네이션 첫째 줄에 두 개의 정수 W와 H가 주어진다. (1 ≤ W, H ≤ 100) 다음 H줄에는 상근이네 집의 건물 배치가 주어진다. i+1줄에는 W개의 정수가 공백으로 구분되어 있다. j번째 (1 ≤ j ≤ w) 정수의 좌표는 www.acmicpc.net 소스 코드 class Queue { constructor() { this.dat = []; this.head = 0; this.tail = 0; } push(item) { this.dat[this.tail++] = item; } pop() { this.head++; } front() { return this.dat[this.head]; } rear() { return this.dat[this.tail - 1]; } isEmpt..

산본개발자
'그래프 탐색' 태그의 글 목록