1. 토마토(7569) 👉 소스코드 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.*; import javax.swing.plaf.synth.SynthSeparatorUI; public class Main { static int width, height, H, notT = 0, count = 0; static int[][][] arr; static int[] moveX = {-1, 1, 0, 0, 0, 0}; static int[] moveY = {0, 0, -1, 1, 0, 0}; sta..
1. 촌수계산(2644)👉 소스코드public class Main { static int total, personA, personB, person; static int result = -1; static int[][] graph; static int[] dist; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); total = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine()); personA ..
1. 단지번호붙이기(2667) 👉 소스코드 public class Main { static int N, count, num; static int[][] arr; static boolean[][] visited; static int[] moveX = {0, 0, -1, 1}; static int[] moveY = {-1, 1, 0, 0}; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); ..
1. 반복수열(2331) 👉 소스코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int A, P; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); ArrayList list = new ArrayList(); A = ..
1. 순열 사이클(10451) 👉 소스코드 public class Main { static int tc, leng; static StringBuilder sb = new StringBuilder(); static int[] arr; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); tc = Integer.parseInt(br.readLine()); for(int i = 0; i < tc; i++) { int count = 0; leng = Integer.parseInt(br.readLine()); arr = new int..
1. BFS 와 DFS란? 대표적인 그래프 탐색 알고리즘 너비 우선 탐색 (Breadth First Search) : 정점들과 같은 레벨에 있는 노드들 (형제 노드들)을 먼저 탐색하는 방식 깊이 우선 탐색 (Depth First Search) : 정점의 자식들을 먼저 탐색하는 방식 BFS/DFS 방식 이해를 위한 예제 BFS 방식 : A - B - C - D - G - H - I - E - F - J 한 단계씩 내려가면서, 해당 노드와 같은 레벨에 있는 노드들 (형제 노드들)을 먼저 순회함 DFS 방식 : A - B - D - E - F - C - G - H - I - J 한 노드의 자식을 타고 끝까지 순회한 후, 다시 돌아와서 다른 형제들의 자식을 타고 내려가며 순회함 2. JAVA로 그래프를 표현하는..