Skip to content

Commit 7633c8e

Browse files
authored
[20251125] BOJ / G3 / 원숭이 스포츠 / 이인희
1 parent 0ca3412 commit 7633c8e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
```java
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.util.*;
6+
7+
public class Main{
8+
private static int N;
9+
private static char[] Arr;
10+
public static void main(String[] args) throws IOException {
11+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12+
N = Integer.parseInt(br.readLine());
13+
Arr = new char[N];
14+
Deque<int[]> q = new ArrayDeque<>();
15+
Deque<int[]> buffer = new ArrayDeque<>();
16+
q.add(new int[]{0, N/2, 0});
17+
q.add(new int[]{N/2, N, 1});
18+
for(int i = 0; i<7; i++){
19+
while(!q.isEmpty()){
20+
int[] temp = q.poll();
21+
int s = temp[0]; int e = temp[1]; int isB = temp[2];
22+
putString(s, e, isB);
23+
24+
if(s + 1 < e){
25+
buffer.add(new int[]{s, (s + e)/2, 0});
26+
buffer.add(new int[]{(s + e)/2, e, 1});
27+
}
28+
}
29+
while(!buffer.isEmpty()){
30+
q.add(buffer.poll());
31+
}
32+
System.out.println(String.valueOf(Arr));
33+
}
34+
// putString(0, N/2, false)+putString(N/2, N, true); // (0, N/2, false), (N/2, N, true)
35+
// putString(0, N/4, false) + putString(N/4, N/2, true)
36+
37+
br.close();
38+
}
39+
40+
private static void putString(int start, int end, int isB){
41+
for(int i = start; i<end; i++)
42+
Arr[i] = (isB==1) ? 'B':'A';
43+
}
44+
}
45+
```

0 commit comments

Comments
 (0)