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
- 문제해결
- SQL
- 알고리즘
- db
- BFS
- 러닝일지
- 문자열
- MySQL
- 투포인터
- 자바
- 프로그래머스
- dfs
- SWEA
- 시뮬레이션
- priorityqueue
- oracle
- 문제풀이
- 코딩테스트
- 이분탐색
- 운동기록
- COS PRO
- binary search
- BOJ
- 백준
- 건강
- 코테
- Java
- greedy
- DP
- math
Archives
- Today
- Total
슈콩
[SWEA] 삼삼 트리플 게임 본문


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWgqpQV6r8gDFAW0
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));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
int[] R = new int[10];
int[] G = new int[10];
int[] B = new int[10];
String nums = br.readLine();
String colors = br.readLine();
for(int i=0;i<9;i++) {
int num = Integer.valueOf(nums.charAt(i)-'0');
char c = colors.charAt(i);
if(c=='R') R[num]++;
else if(c=='G') G[num]++;
else B[num]++;
}
String result = "Continue";
int cnt = 0;
for(int i=1;i<=7;i++) {
while(R[i]>0 && R[i+1]>0 && R[i+2]>0) {
R[i]--; R[i+1]--; R[i+2]--;
cnt++;
}
while(B[i]>0 && B[i+1]>0 && B[i+2]>0) {
B[i]--; B[i+1]--; B[i+2]--;
cnt++;
}
while(G[i]>0 && G[i+1]>0 && G[i+2]>0) {
G[i]--; G[i+1]--; G[i+2]--;
cnt++;
}
}
for(int i=1;i<=9;i++) {
while(R[i]>=3) {
cnt++;
R[i] -= 3;
}
while(G[i]>=3) {
cnt++;
G[i] -= 3;
}
while(B[i]>=3) {
cnt++;
B[i] -= 3;
}
}
if(cnt>=3) System.out.println("#"+tc+" Win");
else System.out.println("#"+tc+" Continue");
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 집합 비교 (0) | 2025.11.20 |
|---|---|
| [SWEA] 새샘이와 세 소수 (0) | 2025.11.20 |
| [SWEA] 세영이의 SEM력 연도 (0) | 2025.11.19 |
| [SWEA] 조 만들기 (0) | 2025.11.19 |
| [SWEA] 2016년 요일 맞추기 (0) | 2025.11.19 |