목록dfs (31)
-

# 주소 https://www.acmicpc.net/problem/19236 19236번: 청소년 상어 첫째 줄부터 4개의 줄에 각 칸의 들어있는 물고기의 정보가 1번 행부터 순서대로 주어진다. 물고기의 정보는 두 정수 ai, bi로 이루어져 있고, ai는 물고기의 번호, bi는 방향을 의미한다. 방향 bi는 www.acmicpc.net # 문제 # 문제 해설 및 코드 리뷰 import java.util.*; class Fish{ int num; int x; int y; int dir; int alive; Fish(int num, int x, int y, int dir, int alive){ this.num = num; this.x = x; this.y = y; this.dir = dir; this.al..

단어 변환 # 주소 https://programmers.co.kr/learn/courses/30/lessons/43163 코딩테스트 연습 - 단어 변환 두 개의 단어 begin, target과 단어의 집합 words가 있습니다. 아래와 같은 규칙을 이용하여 begin에서 target으로 변환하는 가장 짧은 변환 과정을 찾으려고 합니다. 1. 한 번에 한 개의 알파벳만 바꿀 수 programmers.co.kr # 문제 # 문제 해설 및 코드 리뷰 class Solution { static boolean[] visit; static int answer = Integer.MAX_VALUE; public int solution(String begin, String target, String[] words) { ..

# 주소 https://www.acmicpc.net/problem/18513 18513번: 샘터 첫째 줄에 자연수 N과 K가 공백을 기준으로 구분되어 주어진다. (1 ≤ N, K ≤ 100,000) 둘째 줄에 N개의 샘터의 위치가 공백을 기준으로 구분되어 정수 형태로 주어진다. (-100,000,000 ≤ 샘터의 위치 ≤ www.acmicpc.net # 문제 # 문제 해설 및 코드 리뷰 import java.util.*; class Direction{ int x; int dist; Direction(int x, int dist){ this.x = x; this.dist = dist; } } class Main{ static int n,m; static int[] dx = {-1,1}; static Has..

# 주소 https://www.acmicpc.net/problem/5547 5547번: 일루미네이션 첫째 줄에 두 개의 정수 W와 H가 주어진다. (1 ≤ W, H ≤ 100) 다음 H줄에는 상근이네 집의 건물 배치가 주어진다. i+1줄에는 W개의 정수가 공백으로 구분되어 있다. j번째 (1 ≤ j ≤ w) 정수의 좌표는 www.acmicpc.net # 문제 # 문제 해설 및 코드 리뷰 package com.core.hello; import java.awt.*; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; class Main{ static int n, m; static int[][] arr; static in..

# 주소 https://www.acmicpc.net/problem/18808 18808번: 스티커 붙이기 혜윤이는 최근에 다양한 대회를 참여하면서 노트북에 붙일 수 있는 스티커들을 많이 받았다. 스티커는 아래와 같이 사각 모눈종이 위에 인쇄되어 있으며, 스티커의 각 칸은 상하좌우로 모두 연 www.acmicpc.net # 문제 # 문제 해설 및 코드 리뷰 import java.util.*; class Main { static int n,m,k,a,b; static int[][] arr; static int[][] ans; public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); m =..

# 주소 https://www.acmicpc.net/problem/2961 2961번: 도영이가 만든 맛있는 음식 첫째 줄에 재료의 개수 N(1 ≤ N ≤ 10)이 주어진다. 다음 N개 줄에는 그 재료의 신맛과 쓴맛이 공백으로 구분되어 주어진다. 모든 재료를 사용해서 요리를 만들었을 때, 그 요리의 신맛과 쓴맛은 www.acmicpc.net # 문제 # 문제 해설 및 코드 리뷰 import java.util.Arrays; import java.util.Scanner; public class Main { static int n; static int[][] arr; static int sum = Integer.MAX_VALUE; static boolean visit[]; public static void m..