benchmarks.wiki / Public workspace
Humanity's Last Code Exam / 2016_K / String Theory
Problem
Answer published by the source. Consult the official source to check your work against its answer.
question title
String Theory
question content
## Problem Description
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-quotations, which are defined as follows.
A **1-quotation** is a string that begins with a quote character, ends with another quote character, and contains no quote characters in-between. These are just the usual (unnested) quotations. For example, `'this is a string'` is a 1-quotation.
For , a **k-quotation** is a string that begins with quote characters, ends with another quote characters, and contains a nested string in-between. The nested string is a non-empty sequence of -quotations, which may be preceded, separated, and/or succeeded by any number of non-quote characters. For example, `''All 'work' and no 'play'''` is a 2-quotation.
Given a description of a string, you must determine its maximum possible nesting level.
## Input
The input consists of two lines.
- The first line contains an integer .
- The second line contains integers , which describe a string as follows.
The string starts with quote characters, which are followed by a positive number of non-quote characters, which are followed by quote characters, which are followed by a positive number of non-quote characters, and so on, until the string ends with quote characters.
## Output
Display the largest number such that a string described by the input is a k-quotation. If there is no such , display `no quotation` instead.
## Sample Input and Output
### Sample Input 1
Plain-text mathematical notation (without MathML)
## Problem Description 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-quotations, which are defined as follows. A **1-quotation** is a string that begins with a quote character, ends with another quote character, and contains no quote characters in-between. These are just the usual (unnested) quotations. For example, `'this is a string'` is a 1-quotation. For k>1, a **k-quotation** is a string that begins with k quote characters, ends with another k quote characters, and contains a nested string in-between. The nested string is a non-empty sequence of (k−1)-quotations, which may be preceded, separated, and/or succeeded by any number of non-quote characters. For example, `''All 'work' and no 'play'''` is a 2-quotation. Given a description of a string, you must determine its maximum possible nesting level. ## Input The input consists of two lines. - The first line contains an integer n (1≤n≤100). - The second line contains n integers a₁,a₂,…,a_(n) (1≤a_(i)≤100), which describe a string as follows. The string starts with a₁ quote characters, which are followed by a positive number of non-quote characters, which are followed by a₂ quote characters, which are followed by a positive number of non-quote characters, and so on, until the string ends with a_(n) quote characters. ## Output Display the largest number k such that a string described by the input is a k-quotation. If there is no such k, display `no quotation` instead. ## Sample Input and Output ### Sample Input 1
Original LaTeX notation
## Problem Description 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-quotations, which are defined as follows. A **1-quotation** is a string that begins with a quote character, ends with another quote character, and contains no quote characters in-between. These are just the usual (unnested) quotations. For example, `'this is a string'` is a 1-quotation. For \( k > 1 \), a **k-quotation** is a string that begins with \( k \) quote characters, ends with another \( k \) quote characters, and contains a nested string in-between. The nested string is a non-empty sequence of \((k - 1)\)-quotations, which may be preceded, separated, and/or succeeded by any number of non-quote characters. For example, `''All 'work' and no 'play'''` is a 2-quotation. Given a description of a string, you must determine its maximum possible nesting level. ## Input The input consists of two lines. - The first line contains an integer \( n \) \((1 \leq n \leq 100)\). - The second line contains \( n \) integers \( a_1, a_2, \ldots, a_n \) \((1 \leq a_i \leq 100)\), which describe a string as follows. The string starts with \( a_1 \) quote characters, which are followed by a positive number of non-quote characters, which are followed by \( a_2 \) quote characters, which are followed by a positive number of non-quote characters, and so on, until the string ends with \( a_n \) quote characters. ## Output Display the largest number \( k \) such that a string described by the input is a k-quotation. If there is no such \( k \), display `no quotation` instead. ## Sample Input and Output ### Sample Input 1
Code
5
2 1 1 1 3
### Sample Output 1
Code
2
### Sample Input 2
Code
1
22
### Sample Output 2
Code
4
### Sample Input 3
Code
1
1
### Sample Output 3
Code
no quotation
platform
atcoder
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import