K. String Theory
의견: 0
Nested quotations are great not only for writing literature with a complex narrative structure, but also in programming languages. While it may seem necessary to use different quotation marks at different nesting levels for clarity, there is an alternative. We can display various nesting levels using \(k-qu\)otations, which are defined as follows. A \(1-qu\)otation is a string that begins with a quote character, ends with another quote character and contains no quote characters \(in-be\)tween. These are just the usual (unnested) quotations. For example, 'this is a string' is a \(1-qu\)otation. For \(k > 1\), a \(k-qu\)otation is a string that begins with \(k\) quote characters, ends with another \(k\) quote characters and contains a nested string \(in-be\)tween. The nested string is a n\(on-em\)pty sequence of (\(k - 1\))-quotations, which may be preceded, separated, a\(nd/or\) succeeded by any number of n\(on-qu\)ote characters. For example, ''All 'work' and no 'play''' is a \(2-qu\)otation. Given a description of a string, you must determine its maximum possible nesting level.
The input consists of two lines. The first line contains an integer \(n\) (\(1 \le n \le 100\)). The second line contains \(n\) integers \(a_{1}\), a_{2}, . . . , a_{n} (\(1 \le a_{i} \le 100\)), which describe a string as follows. The string starts with \(a\)1 quote characters, which are followed by a positive number of n\(on-qu\)ote characters, which are followed by \(a\)2 quote characters, which are followed by a positive number of n\(on-qu\)ote characters, and so on, until the string ends with \(an\) quote characters.
Display the largest number \(k\) such that a string described by the input is a \(k-qu\)otation. If there is no such \(k\), display no quotation instead.
5
2 1 1 1 3
2
1
22
4
1
1
no quotation
평가 및 의견
K. String Theory
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
K. String Theory