Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 문자열
- SWEA
- oracle
- BOJ
- greedy
- 코테
- 자바
- COS PRO
- SQL
- Java
- math
- 프로그래머스
- 백준
- 투포인터
- 알고리즘
- DP
- 운동기록
- 러닝일지
- MySQL
- 이분탐색
- binary search
- 문제해결
- db
- BFS
- dfs
- 코딩테스트
- priorityqueue
- 문제풀이
- 시뮬레이션
- 건강
Archives
- Today
- Total
슈콩
[SWEA] 격자판 칠하기 본문

[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYEXgKnKKg0DFARx
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
static int n,m;
static char[][] map;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
map = new char[n][m];
for(int i=0;i<n;i++) {
map[i] = br.readLine().toCharArray();
}
if(check('#','.') || check('.','#')) {
System.out.println("#"+tc+" possible");
}
else System.out.println("#"+tc+" impossible");
}
}
private static boolean check(char a,char b) {
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
if((i+j)%2==0 && map[i][j]==a) {
return false;
}
if((i+j)%2==1 && map[i][j]==b) {
return false;
}
}
}
return true;
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 준환이의 운동관리 (0) | 2025.11.14 |
|---|---|
| [SWEA] 정사각형 판정 (0) | 2025.11.14 |
| [SWEA] 식료품 가게 (0) | 2025.11.14 |
| [SWEA] 5일차 - GNS (0) | 2025.11.14 |
| [SWEA] 삼성시의 버스 노선 (0) | 2025.11.14 |