Loading...

ABC 339 D번 복기 - 4차원 visited 배열 BFS 백트래킹

1. 문제 D - Synchronized Players (atcoder.jp) D - Synchronized Players AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online. atcoder.jp 2. 풀이 하라는대로 구현하면 된다 두 플레이어 P가 움직이는데 두 플레이어는 같은 방향으로 움직이게 되어있다. 또한 한 플레이어가 해당 방향으로 움직일수 없더라도 다른 플레이어가 움직일 수 있다면 움직이는 경우로 생각한다 그래서 먼저 두 플레이어의 위치를 찾고 BFS를 수행하는 전형적인 형태 n = int(stdin.readline()) maps = ..

2023. 3. 1. 17:02

자바 초보부터 B형까지8 -2차원 배열 필수-

1. 2차원 배열 선언 정수형 2차원 배열은 new int[행 개수][열 개수];로 선언 가능하다 int[][] arr2d = new int[4][4]; 2차원 격자상 좌표가 (x,y)라고 한다면.. y행 x열에 대한 원소 접근은 arr2d[y][x];와 같이 접근할 수 있다. /* i/j 0 1 2 3 0 1 2 3 4 1 7 8 9 10 2 11 12 13 14 3 15 16 17 18 */ public class Main { public static void main(String[] args) { int[][] arr2d = new int[][]{ {1, 2, 3, 4}, {7, 8, 9, 10}, {11, 12, 13, 14}, {15, 16, 17, 18} }; System.out.println..