From ee1e97c658183125aef777f6f7b61051d86960c3 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Wed, 5 Feb 2025 16:15:51 +0900 Subject: [PATCH] =?UTF-8?q?[20250205]=20BOJ=20/=20=EC=8B=A4=EB=B2=841=20/?= =?UTF-8?q?=20=EC=98=A4=EB=AA=A9=20/=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\262\2041 \354\230\244\353\252\251.md" | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 "lkhyun/202502/05 BOJ \354\213\244\353\262\2041 \354\230\244\353\252\251.md" diff --git "a/lkhyun/202502/05 BOJ \354\213\244\353\262\2041 \354\230\244\353\252\251.md" "b/lkhyun/202502/05 BOJ \354\213\244\353\262\2041 \354\230\244\353\252\251.md" new file mode 100644 index 00000000..3d331fc9 --- /dev/null +++ "b/lkhyun/202502/05 BOJ \354\213\244\353\262\2041 \354\230\244\353\252\251.md" @@ -0,0 +1,77 @@ +```java +import java.io.FileNotFoundException; +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) throws FileNotFoundException { + Scanner sc = new Scanner(System.in); + int[][] grid = new int[19][19]; + for(int i=0;i<19;i++) { + for(int j=0;j<19;j++) { + grid[i][j] = sc.nextInt(); + } + } + + int[] di = {1,1,0,-1}; + int[] dj = {0,1,1,1}; + for(int i=0;i<19;i++) { + for(int j=0;j<19;j++) { + if(grid[i][j]==1 || grid[i][j]==2) { //흑돌 혹은 백돌이면 + int check = grid[i][j]; + int count = 1; + for(int k=0;k<4;k++) { //팔방탐색 + int newi = i+di[k]; + int newj = j+dj[k]; + if(newi>=0&&newi<19&&newj>=0&&newj<19) {//벗어나지 않으면 + if(grid[newi][newj]==check) {//이전 돌과 같으면 + count=2; + for(int l=0;l<4;l++) {//최대 육목까지 체크 + newi = newi+di[k]; + newj = newj+dj[k]; + if(newi>=0&&newi<19&&newj>=0&&newj<19) { + if(grid[newi][newj]==check){ + if(count==5){break;} + count++; + } + else{ + if(count==5){ + if(i-di[k]>=0&&i-di[k]<19&&j-dj[k]>=0&&j-dj[k]<19) + { + if(grid[i-di[k]][j-dj[k]] == check){ + break; + } + } + System.out.println(check); + System.out.println((i+1)+" "+(j+1)); + return; + } + break; + } + } + else { + if(count==5){ + if(i-di[k]>=0&&i-di[k]<19&&j-dj[k]>=0&&j-dj[k]<19) + { + if(grid[i-di[k]][j-dj[k]] == check){ + break; + } + } + System.out.println(check); + System.out.println((i+1)+" "+(j+1)); + return; + } + break; + } + } + } + } + } + } + } + } + System.out.println("0"); + } + +} +```