백준
-
[백준] 3197 백조의 호수 #JAVA #BFS #시간초과Algorithm Solving/BAEKJOON 2022. 1. 13. 12:10
[백준] 3197 백조의 호수 #JAVA #BFS #시간초과 코드 import java.io.*; import java.util.*; public class Main { static int[] dx = {0,1,0,-1}; static int[] dy = {1,0,-1,0}; static int R, C; static char[][] map; static boolean[][] visSwan, visWater; static Queue waterQ, waterNextQ, swanQ, swanNextQ; static int startX, startY, endX, endY; public static void main(String[] args) throws IOException { BufferedReader br..
-
[백준] 18809 Gaaaaaaaaaarden #JAVA #백트래킹 #bfsAlgorithm Solving/BAEKJOON 2022. 1. 12. 14:34
[백준] 18809 Gaaaaaaaaaarden #JAVA #백트래킹 #bfs 오랜 시간이 걸려서 풀었던 문제. 코드 import java.io.*; import java.util.*; public class Main { static List baeyang; static int N,M,G,R; static int[][] garden; static int[] selectBaeyang; static int[] selectGR; static boolean[] isUsedBaeyang; static int[] spotG, spotR; static int[] dx = {0,1,0,-1}; static int[] dy = {1,0,-1,0}; static int max = 0; public static void m..
-
[백준] 1202 보석 도둑 #JAVA #우선순위 큐Algorithm Solving/BAEKJOON 2021. 12. 26. 14:34
[백준] 1202 보석 도둑 #JAVA #우선순위 큐 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new Inp..
-
[백준] 7662 이중 우선순위 큐 #JAVA #이진 탐색 트리Algorithm Solving/BAEKJOON 2021. 12. 24. 18:15
[백준] 7662 이중 우선순위 큐 #JAVA #이진 탐색 트리 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new S..
-
[백준] 3190 뱀 #JAVA #시뮬레이션Algorithm Solving/BAEKJOON 2021. 12. 17. 13:33
[백준] 3190 뱀 #JAVA #시뮬레이션 코드 import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine());//보드 크기 int K = Integer.parseInt(br.readLine());//사과 개수 int[][] board = new int[N][N]; StringTokenizer st; for (int i = 0; i < K; i++) { //..
-
[백준] 2461 대표선수 #JAVA #투포인터Algorithm Solving/BAEKJOON 2021. 11. 27. 08:01
[백준] 2461 대표선수 #JAVA #투포인터 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { static int N,M; static int count[]; public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); S..
-
[백준] 2143 두 배열의 합 #JAVA #이분탐색Algorithm Solving/BAEKJOON 2021. 11. 18. 20:39
[백준] 2143 두 배열의 합 #JAVA 코드 import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] arrA, arrB; int[] subArrA, subArrB; StringTokenizer stA,stB; long total = 0; // 21억개를 초과하는 경우가 존재 int T = Integer.parseInt(br.readLine()); int N = Integer.parseInt(br.readLin..
-
[백준] 11047 동전0 #JAVAAlgorithm Solving/BAEKJOON 2021. 2. 28. 01:30
[백준] 11047 동전0 #JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken..
-
[백준] 12852 1로 만들기 2#JAVAAlgorithm Solving/BAEKJOON 2021. 2. 27. 18:33
[백준] 12852 1로 만들기 2#JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int n = Integer.parseInt(br.readLine()); int[] d = new int[..
-
[백준] 1149 RGB거리 #JAVAAlgorithm Solving/BAEKJOON 2021. 2. 27. 00:33
[백준] 1149 RGB거리 #JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[][] arr = new int[n+1][3]; //arr[i][j] // i번째 집에..