Untitled diff
4 removals
33 lines
11 additions
40 lines
int n = readInt();
int alphSize = readInt();
String s = readString();
String s = readString();
int n = s.length() + 1;
int[] b = new int[n-1];
int[] b = new int[n-1];
for (int i = 0; i < n-1; i++) {
for (int i = 0; i < n-1; i++) {
if (s.charAt(i) == 'L') b[i] = -1;
if (s.charAt(i) == '>') b[i] = -1;
if (s.charAt(i) == 'R') b[i] = 1;
if (s.charAt(i) == '<') b[i] = 1;
if (s.charAt(i) == '=') b[i] = 0;
if (s.charAt(i) == '=') b[i] = 0;
}
}
int[] a = new int[n];
int[] a = new int[n];
a[0] = 1;
a[0] = 1;
for (int i = 1; i < n; i++) {
for (int i = 1; i < n; i++) {
if (b[i-1] == 1) {
if (b[i-1] == 1) {
a[i] = a[i-1] + 1;
a[i] = a[i-1] + 1;
continue;
continue;
}
}
if (b[i-1] == -1) {
if (b[i-1] == -1) {
a[i] = 1;
a[i] = 1;
for (int j = i-1; j >= 0; j--) {
for (int j = i-1; j >= 0; j--) {
if (a[j] == a[j+1] && b[j] == -1) a[j]++;
if (a[j] == a[j+1] && b[j] == -1) a[j]++;
else if (b[j] == 0) a[j] = a[j+1];
else if (b[j] == 0) a[j] = a[j+1];
else break;
else break;
}
}
continue;
continue;
}
}
if (b[i-1] == 0) {
if (b[i-1] == 0) {
a[i] = a[i-1];
a[i] = a[i-1];
continue;
continue;
}
}
throw new RuntimeException();
throw new RuntimeException();
}
}
for (int i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
out.print(a[i] + " ");
if (a[i] > alphSize) {
out.println(-1);
return;
}
}
for (int i = 0; i < n; i++) {
out.print((char) (a[i] + 'a' - 1));
}
}