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


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AZU2weVqkoPHBIRK
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 n = Integer.parseInt(br.readLine());
int[] a = new int[n];
int[] b = new int[n];
st = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
a[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
b[i] = Integer.parseInt(st.nextToken());
}
boolean[] visit = new boolean[n+1];
int[] select = new int[n+1];
int cnt = 0;
while(cnt<n) {
for(int i=0;i<n;i++) {
if(!visit[a[i]]) {
visit[a[i]] = true;
select[a[i]] = 1;
cnt++;
break;
}
}
for(int i=0;i<n;i++) {
if(!visit[b[i]]) {
visit[b[i]] = true;
select[b[i]] = 2;
cnt++;
break;
}
}
}
String result = "";
for(int i=1;i<=n;i++) {
if(select[i]==1) result += "A";
else result += "B";
}
System.out.println(result);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 통나무 자르기 (0) | 2025.11.16 |
|---|---|
| [SWEA] 피보나치 수 분배 (0) | 2025.11.16 |
| [SWEA] 석찬이의 받아쓰기 (0) | 2025.11.16 |
| [SWEA] 직사각형 길이 찾기 (0) | 2025.11.16 |
| [SWEA] 최대 성적표 만들기 (0) | 2025.11.16 |