본문 바로가기

알고리즘/구현

(29)
자바 | 백준 | 21609 | 상어 중학교 Solution import java.io.*; import java.util.*; public class Main { static int N, M; static int[][] map; static boolean[][] visited; static int[] dx = { -1, 1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; static List blockGroup, biggestBlockGroup; public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamRead..
자바 | 백준 | 21611 | 마법사 상어와 블리자드 Solution import java.io.*; import java.util.*; public class Main { static int N, M; static int[][] map; static int[][] index; static int[] dx = { 0, -1, 1, 0, 0 }; static int[] dy = { 0, 0, 0, -1, 1 }; // 북, 남, 서, 동 static int[] dx2 = { 0, 1, 0, -1 }; static int[] dy2 = { 1, 0, -1, 0 }; static int[] d; static int[] s; static int[] bombs = new int[4]; static Coor[] coors; public static void main(..
자바 | 백준 | 20056 | 마법사 상어와 파이어볼 Solution import java.io.*; import java.util.*; public class Main { static int N, M, K; static int[] dx = { -1, -1, 0, 1, 1, 1, 0, -1 }; static int[] dy = { 0, 1, 1, 1, 0, -1, -1, -1 }; static List list; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " ");..
자바 | 백준 | 21608 | 상어 초등학교 Solution import java.io.*; import java.util.*; public class Main { static int N; static int[][] map; static int[] order; static int[][] seats; static int[] dx = { -1, 1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; static int likeCnt, emptyCnt, R, C; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); N = Integer.par..
자바 | 백준 | 17837 | 새로운 게임2 | subList Solution package BOJ; import java.io.*; import java.util.*; public class BOJ_17837_새로운게임2 { static int N, K; static int[][] map; static List list; static int[][] info; static int[] dx = { 0, 0, 0, -1, 1 }; static int[] dy = { 0, 1, -1, 0, 0 }; public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReade..
자바 | 백준 | 12100 | 2048(Easy) Solution: 이동횟수가 5가 될 때까지 DFS 탐색 한 번 할 때마다 사방으로 옮긴 경우를 모두 구함 package BOJ; import java.io.*; import java.util.*; public class BOJ_12100_2048_Easy { static int N; static int[][] map; static Deque dq; static int max = 0; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); N = Integer.parseInt(br.readLine()); map = new ..
파이썬 | 백준 | 7453 | 합이 0인 네 정수 Solution. dictionary # 7453, 합이 0인 네 정수 import sys from collections import defaultdict A, B, C, D = [], [], [], [] N = int(sys.stdin.readline()) for i in range(N): a, b, c, d = map(int, sys.stdin.readline().split()) A.append(a) B.append(b) C.append(c) D.append(d) # abPlus = defaultdict(int) # for a in A: # for b in B: # abPlus[a+b] = abPlus[a+b]+1 # # count = 0 # for c in C: # for d in D: # coun..
자바 | 백준 | 16236 | 아기 상어 Solution 최단 거리 → BFS // 16236, 아기 상어 | https://www.acmicpc.net/problem/16236 package BOJ; import java.io.*; import java.util.*; public class BOJ_16236 { static int N; static int[][] map; static int[] dx = { -1, 0, 0, 1 }; static int[] dy = { 0, -1, 1, 0 }; static int time = 0; // 몇 초 동안 static int weight = 0; // 먹은 물고기 수 static int shark = 2; // 아기상어 크기 초기값 public static void main(String[] args)..