-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3499.java
More file actions
48 lines (38 loc) ยท 1.07 KB
/
Copy path3499.java
File metadata and controls
48 lines (38 loc) ยท 1.07 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t=1; t<=T; t++) {
int N = sc.nextInt();
String[] arr = new String[N+1];
for(int i=1; i<=N; i++)
arr[i] = sc.next();
int H = parseH(N); // ์ฒซ๋ฒ์งธ๋ก ๋ผ์๋ฃ์ ์นด๋ ์ธ๋ฑ์ค ํ์ฑ
ArrayList<String> result = new ArrayList<>();
result.add(arr[1]); // ์ฒซ๋ฒ์งธ ์นด๋๋ ๋ฏธ๋ฆฌ ๋ฃ์ด๋๊ธฐ
int idx = 2;
for(int i=H; i<=N; i++) {
result.add(arr[i]);
// ์นด๋๊ฐ ํ์๊ฐ๋ฉด ์๊ด์์ง๋ง, ์ง์๊ฐ๋ฉด ๋ง์ง๋ง ์นด๋๋ ์๋ฃ์ด์ผํจ.
if(N%2==0 && i!=N)
result.add(arr[idx++]);
if(N%2 == 1)
result.add(arr[idx++]);
}
// ์ ๋ต ์ถ๋ ฅ
System.out.print("#" + t + " ");
for(int i=0; i<result.size(); i++)
System.out.print(result.get(i) + " ");
System.out.println();
}
}
private static int parseH(int N) {
if(N%2 == 0) {
return N/2+1;
}
return N/2+2;
}
}