-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathCodeforces_0746B_Decoding.java
More file actions
38 lines (37 loc) · 1 KB
/
Codeforces_0746B_Decoding.java
File metadata and controls
38 lines (37 loc) · 1 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
// AC: 202 ms
// Memory: 0 KB
// .
// T:O(n), S:O(n)
//
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Codeforces_0746B_Decoding {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s = sc.next();
StringBuilder ret = new StringBuilder();
Deque<Character> list = new ArrayDeque<>();
list.add(s.charAt(0));
for (int i = 1; i < n; i++) {
if (n % 2 == 0) {
if (i % 2 == 1) {
list.addLast(s.charAt(i));
} else {
list.addFirst(s.charAt(i));
}
} else {
if (i % 2 == 1) {
list.addFirst(s.charAt(i));
} else {
list.addLast(s.charAt(i));
}
}
}
for (char c : list) {
ret.append(c);
}
System.out.println(ret);
}
}