QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB Puntuación total: 100

#4372. 字符串理论

Estadísticas

嵌套引用不仅对于编写具有复杂叙事结构的文学作品非常有用,在编程语言中也同样如此。虽然为了清晰起见,在不同的嵌套层级使用不同的引号似乎很有必要,但其实还有另一种选择。我们可以使用 $k$-引用来表示各种嵌套层级,其定义如下:

$1$-引用是一个以引号字符开头,以另一个引号字符结尾,且中间不包含任何引号字符的字符串。这仅仅是通常的(未嵌套的)引用。例如,'this is a string' 是一个 $1$-引用。

对于 $k > 1$,$k$-引用是一个以 $k$ 个引号字符开头,以另外 $k$ 个引号字符结尾,且中间包含一个嵌套字符串的字符串。该嵌套字符串是一个非空的 $(k-1)$-引用序列,这些引用序列的前面、中间和/或后面可以有任意数量的非引号字符。例如,''All 'work' and no 'play''' 是一个 $2$-引用。

给定一个字符串的描述,你必须确定其最大可能的嵌套层级。

输入格式

输入包含两行。第一行包含一个整数 $n$ ($1 \le n \le 100$)。第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$),它们描述了一个字符串,具体如下:该字符串以 $a_1$ 个引号字符开头,后面跟着正数个非引号字符,接着是 $a_2$ 个引号字符,后面跟着正数个非引号字符,依此类推,直到字符串以 $a_n$ 个引号字符结尾。

输出格式

输出最大的整数 $k$,使得输入所描述的字符串是一个 $k$-引用。如果不存在这样的 $k$,则输出 no quotation

样例

样例输入 1

5
2 1 1 1 3

样例输出 1

2

样例输入 2

1
22

样例输出 2

4

样例输入 3

1
1

样例输出 3

no quotation

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.