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


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXAdrmW61ssDFAXq
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
static int n,result;
static String[] words;
static boolean[] visit;
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++) {
n = Integer.parseInt(br.readLine());
words = new String[n];
for(int i=0;i<n;i++) {
words[i] = br.readLine();
}
result = 0;
for(int i=1;i<=n;i++) {
visit = new boolean[n];
combi(0,0,i);
}
System.out.println("#"+tc+" "+result);
}
}
private static void combi(int idx,int cnt,int max) {
if(cnt==max) {
HashSet<Character> hs = new HashSet<>();
for(int i=0;i<n;i++) {
if(visit[i]) {
for(char c : words[i].toCharArray()) {
hs.add(c);
}
}
}
if(hs.size()==26) result++;
return;
}
for(int i=idx;i<n;i++) {
if(!visit[i]) {
visit[i] = true;
combi(i+1,cnt+1,max);
visit[i] = false;
}
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 코딩 토너먼트1 (0) | 2025.11.15 |
|---|---|
| [SWEA] 영준이의 카드 카운팅 (0) | 2025.11.15 |
| [SWEA] 이진수 표현 (0) | 2025.11.15 |
| [SWEA] 체스판 위의 룩 배치 (0) | 2025.11.15 |
| [SWEA] 무한 문자열 (0) | 2025.11.15 |