본문 바로가기

알고리즘/DFS, BFS, 시뮬, 백트래킹9

[백준] 24479번 알고리즘 수업 - 깊이 우선 탐색 1 #Java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class Main { static int N,M,R,idx; static ArrayList[] edges; static int [] answer; static boolean [] visited; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedRead.. 2022. 6. 17.
[백준] 7562번 나이트의 이동 #Java bfs 간단한 문제 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; class Point{ int x,y; public Point(int x,int y){ this.x = x; this.y = y; } } public class Main { static int dx[] = {-1,-2,-2,-1,1,2,2,1}; static int dy[] = {-2,-1,1,2,2,1,-1,-2}; static int [][] arr; static .. 2022. 5. 27.
[백준] 2578번 빙고 #Java 시뮬레이션. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int [][] arr; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; arr = new int[5][5]; int [] call = new int [25]; for (int i = 0; i < .. 2022. 5. 25.
[백준] 2630번 색종이 만들기 import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int [][] arr = new int[n][n]; for (int i = 0; i < n; i++) { String[] s = br.readLine().split(" "); for (int j = 0; j < n; j++) { arr[i][j] =.. 2022. 5. 17.