BFS
-
[BOJ - Silver II] 촌수계산 / ⭕Algorithm/BOJ 2024. 8. 21. 11:04
촌수계산1. 제출 코드 (18분 20초 / BFS)import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayDeque;import java.util.StringTokenizer;public class Main { static int N; static int[][] relation; static boolean[][] visited; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStrea..
-
[BOJ - Gold IV] 녹색 옷 입은 애가 젤다지? / ⭕Algorithm/BOJ 2024. 8. 19. 16:52
녹색 옷 입은 애가 젤다지?1. 제출 코드 (39분 29초 / BFS)import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayDeque;import java.util.Arrays;import java.util.PriorityQueue;import java.util.StringTokenizer;public class BOJ_4485 { static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, -1, 1}; static int N; public static void main(String[] args..
-
[BOJ - Gold V] 토마토 / ⭕Algorithm/BOJ 2024. 8. 17. 15:46
토마토1. 제출 코드 (31분 26초 / BFS)import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayDeque;import java.util.ArrayList;import java.util.StringTokenizer;public class Main { static class Pos { int x, y; public Pos(int x, int y) { this.x = x; this.y = y; } } static int N, M; static int[][] to..
-
[Programmers] 무인도 여행 / ⭕Algorithm/Programmers 2024. 7. 16. 13:59
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (19분 33초 / BFS)import java.util.*;class Solution { static ArrayList[] map; static boolean[][] visited; static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, -1, 1}; public ArrayList solution(String[] maps) { ArrayList answer = new ArrayList(); ..
-
[Programmers] 미로 탈출 / ⭕Algorithm/Programmers 2024. 7. 10. 15:12
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (26분 25초 / BFS)import java.util.*;class Solution { static class Pos { int x; int y; int dist; public Pos(int x, int y, int dist) { this.x = x; this.y = y; this.dist = dist; } } static int[] dx = {-1, 1, ..
-
[Programmers] 리코쳇 로봇 / ⭕Algorithm/Programmers 2024. 7. 9. 14:40
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (41분 25초 / BFS)import java.util.*;class Solution { static class Pos { int x, y, dist; public Pos(int x, int y, int dist) { this.x = x; this.y = y; this.dist = dist; } } static int[] dx = {-1, 1, 0, 0}; static int[]..