슈콩

[SWEA] 체스판 위의 룩 배치 본문

Algorithms/SWEA

[SWEA] 체스판 위의 룩 배치

shukong 2025. 11. 15. 17:56

 

 

[문제]

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYOBfxwaAXsDFATW

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Solution {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int T = Integer.parseInt(br.readLine());
		for(int tc=1;tc<=T;tc++) {
			char[][] map = new char[8][8];
			boolean[] row = new boolean[8];
			boolean[] col = new boolean[8];
			boolean result = true;
			for(int i=0;i<8;i++) {
				map[i] = br.readLine().toCharArray();
			}
			int cnt = 0;
			for(int i=0;i<8;i++) {
				for(int j=0;j<8;j++) {
					if(map[i][j]=='O') {
						if(!row[i] && !col[j]) {
							cnt++;
						}
						else result = false;
						row[i] = col[j] = true;
					}
				}
			}
			if(cnt!=8) result = false;
			if(!result) System.out.println("#"+tc+" no");
			else System.out.println("#"+tc+" yes");
		}
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 민정이와 광직이의 알파벳 공부  (0) 2025.11.15
[SWEA] 이진수 표현  (0) 2025.11.15
[SWEA] 무한 문자열  (0) 2025.11.15
[SWEA] 팰린드롬 문제  (0) 2025.11.15
[SWEA] 화섭이의 정수 나열  (0) 2025.11.15