forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe3499.java
More file actions
65 lines (46 loc) · 1.32 KB
/
swe3499.java
File metadata and controls
65 lines (46 loc) · 1.32 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class swe3499 {
static Queue<String> Que1 = new LinkedList<>();
static Queue<String> Que2 = new LinkedList<>();
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int T = sc.nextInt();
String answer;
//테스트케이스
for(int t=0; t<T; t++) {
//초기화
double N = sc.nextDouble();
int Temp = (int)Math.round(N/2);
Que1.clear();
Que2.clear();
answer = "";
for(int i =0; i<Temp; i++)
{
Que1.offer(sc.next());
}
for(int i=Temp; i<N; i++)
{
Que2.offer(sc.next());
}
answer = solution();
System.out.println("#" + (t+1) + " " + answer);
}
}
public static String solution()
{
String buffer = "";
while(true)
{
if(!Que1.isEmpty())
buffer = buffer + Que1.poll() + " ";
if(!Que2.isEmpty())
buffer = buffer + Que2.poll() + " ";
if(Que1.isEmpty() && Que2.isEmpty())
break;
}
return buffer;
}
}