From fdd446789d319b21c620675f59271ef48a93cd6d Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:13:28 +0900 Subject: [PATCH] =?UTF-8?q?[20251028]=20BOJ=20/=20G4=20/=20=EC=A3=BC?= =?UTF-8?q?=EC=82=AC=EC=9C=84=20=EA=B5=B4=EB=A6=AC=EA=B8=B0=20/=20?= =?UTF-8?q?=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \352\265\264\353\246\254\352\270\260.md" | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 "lkhyun/202510/28 BOJ G4 \354\243\274\354\202\254\354\234\204 \352\265\264\353\246\254\352\270\260.md" diff --git "a/lkhyun/202510/28 BOJ G4 \354\243\274\354\202\254\354\234\204 \352\265\264\353\246\254\352\270\260.md" "b/lkhyun/202510/28 BOJ G4 \354\243\274\354\202\254\354\234\204 \352\265\264\353\246\254\352\270\260.md" new file mode 100644 index 00000000..74e94276 --- /dev/null +++ "b/lkhyun/202510/28 BOJ G4 \354\243\274\354\202\254\354\234\204 \352\265\264\353\246\254\352\270\260.md" @@ -0,0 +1,101 @@ +```java +import java.util.*; +import java.io.*; + +public class Main{ + static class State{ + int x,y; + int[] row = new int[3]; + int[] col = new int[3]; + State(int x, int y){ + this.x = x; + this.y = y; + } + public void rolling(int direction, int[][] map) throws Exception{ + if(direction == 1){ //동쪽 + if(y == map[0].length-1) return; + int temp = col[2]; + col[2] = row[2]; + row[2] = row[1]; + row[1] = row[0]; + row[0] = temp; + y++; + check(); + return; + } + if(direction == 2){ //서쪽 + if(y == 0) return; + int temp = col[2]; + col[2] = row[0]; + row[0] = row[1]; + row[1] = row[2]; + row[2] = temp; + y--; + check(); + return; + } + if(direction == 3){ //북쪽 + if(x == 0) return; + int temp = col[2]; + col[2] = col[0]; + col[0] = row[1]; + row[1] = col[1]; + col[1] = temp; + x--; + check(); + return; + } + if(direction == 4){ //남쪽 + if(x == map.length-1) return; + int temp = col[2]; + col[2] = col[1]; + col[1] = row[1]; + row[1] = col[0]; + col[0] = temp; + x++; + check(); + return; + } + } + public void check() throws Exception{ + if(map[x][y] == 0){ + map[x][y] = col[2]; + }else{ + col[2] = map[x][y]; + map[x][y] = 0; + } + bw.write(row[1]+"\n"); + } + } + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + static int N,M,X,Y,K; + static int[][] map; + public static void main(String[] args) throws Exception { + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + X = Integer.parseInt(st.nextToken()); + Y = Integer.parseInt(st.nextToken()); + K = Integer.parseInt(st.nextToken()); + + map = new int[N][M]; + for(int i = 0; i