-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrthography.java
42 lines (30 loc) · 968 Bytes
/
Orthography.java
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
import java.util.*;
import java.io.*;
public class Orthography
{
public static int fromPos = 0;
public static void main(String[] argv) {
Scanner in = new Scanner(System.in).useLocale(Locale.US);
PrintWriter out = new PrintWriter(System.out);
char got[] = in.nextLine().toCharArray();
// warn(new String(got));
char decoded[] = new char[got.length];
decode(decoded, got, 0, got.length-1);
warn (new String(decoded));
}
public static void decode(char[] to, char[] from, int toStart, int toEnd) {
if (toEnd < toStart) {
return;
}
int m = toStart + (toEnd-toStart)/2;
to[m] = from[fromPos++];
decode(to, from, toStart, m-1);
decode(to, from, m+1, toEnd);
}
public static final boolean DEBUG = true;
public static void warn(String s) {
if (DEBUG) {
System.out.println(s);
}
}
}