Problem B
Space Alignment
You are collaborating with a few other programmers on a coding project. To your horror, you discover that some people have been using tabs to indent code while other people have been using spaces to indent code within the same file. Apparently these people didn’t notice that anything was amiss when they did so.
You wish to replace the tabs with spaces so that the file
has consistent indenting. Consistent indenting means that for
every line at a nesting depth of
Is it possible to replace each tabs with a fixed number of spaces to repair the file and have consistent indenting?
Input
The first line of input contains a single integer
Each of the next
The first line is guaranteed to be a single ‘{’, the last line is guaranteed to be a single ‘}’, and the braces throughout the data are guaranteed to match; that is, looking at only those characters as a single string, it is always possible to repeatedly remove a substring “{}” until you are left with the empty string.
Output
Output a single integer, which is the smallest number of
spaces greater than zero to replace each tab with and achieve
consistent indentation, or
Sample Input 1 | Sample Output 1 |
---|---|
10 { ss{ sts{ tt} t} t{ ss} } { } |
2 |