import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class boj1248 {
static int N;
static String matrix;
static char[][] mat;
static int[] res;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
matrix = st.nextToken();
mat = new char[N][N];
int idx = 0;
for(int i = 0 ; i < N ; i++){
for(int j = i ; j < N ; j++){
mat[i][j] = matrix.charAt(idx++);
}
}
res = new int[N];
DFS(0);
}
static void DFS(int depth){
if(depth == N){
printArray(res);
System.out.print(sb);
System.exit(0);
}
for(int i = -10; i <= 10; i++){
res[depth] = i;
if(check(depth)){
DFS(depth + 1);
}
}
}
private static boolean check(int index) {
for(int i = 0 ; i <= index ; i++){
int sum = 0;
for (int j = i; j <= index ; j++){
sum += res[j];
if(mat[i][j] !=
(sum == 0 ? '0' : (sum > 0 ? '+' : '-')))
return false;
}
}
return true;
}
public static void printArray(int[] arr){
for(int i = 0; i < arr.length ; i++){
sb.append(arr[i] + " ");
}
sb.append('\n');
}
}
Leave a comment