알고리즘/부루트포스 [swea] 11315. 오목 판정(Java 풀이) - https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXaSUPYqPYMDFASQ SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com import java.util.Scanner; public class Solution { static int[] dx = { -1, 0, 1, 1 }; static int[] dy = { 1, 1, 1, 0 }; static int N; static String ans; static char[][] arr; public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 테스트케이스 수 int T = sc.nextInt(); for (int tc = 1; tc <= T; tc++) { N = sc.nextInt(); ans = "NO"; sc.nextLine(); // 개행문자 제거 arr = new char[N][]; // 바둑판 입력 for (int i = 0; i < N; i++) { String tmp = sc.nextLine(); arr[i] = tmp.toCharArray(); } // 오목 검증 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (arr[i][j] == 'o' && check(i, j)) { break; } } } System.out.printf("#%d %s\n", tc, ans); } } static boolean check(int x, int y) { for (int i = 0; i < 4; i++) { int cnt = 1; for (int j = 1; j < 5; j++) { int nx = x + dx[i] * j; int ny = y + dy[i] * j; if (nx < 0 || nx >= N || ny < 0 || ny >= N || arr[nx][ny] != 'o') { break; } cnt++; } if (cnt >= 5) { ans = "YES"; return true; } } return false; } } 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기파프리카의 IT블로그 Contents 당신이 좋아할만한 콘텐츠 [백준 20529] 가장 가까운 세 사람의 심리적 거리 (파이썬 풀이) 2023.07.24 [백준 1107] 리모컨 (파이썬 풀이) 2023.05.04 댓글 0 + 이전 댓글 더보기