IBMOA #70
Table of Contents
Estimated EasyJudge-ready
Topics (AI-labelled)StringsSimulation
A line that starts exactly with "# " is a chapter title, a line that starts with "## " is a section title, and all other lines are ignored. Chapters are numbered from 1, and section numbers restart from 1 in each new chapter; output "<chapter>. <title>" or "<chapter>.<section>. <title>". Only the fixed prefix is removed; all whitespace and Unicode characters within the title are kept as is, and empty titles are allowed.
Input
The input is a JSON array of strings text. Full original bounds: 1≤number of lines≤1000, and each string has length 1..100 in Unicode code points; the first line is guaranteed to start with "# ". A leading # marker is only # or ## and is followed by a space. The original text does not restrict the character set, so it is not narrowed to ASCII; JSON escapes may represent control characters such as tabs, and title content is not trimmed.
Output
Output a single-line canonical JSON array of strings, followed by a newline: one space after each comma in the array; non-ASCII characters are output directly; double quotes, backslashes and control characters are escaped per JSON (backspace/tab/newline/form feed/carriage return use \b/\t/\n/\f/\r, and the remaining U+0000..U+001F use lowercase four-digit \u00xx); slashes are not escaped. This matches Python json.dumps(result, ensure_ascii=False). This encoding preserves every title character and avoids NUL in the output; an exact check is used.
Example 1
Input:
["# Cars", "ignored", "## Sedan", "## Coupe", "## SUV"]
Output:
["1. Cars", "1.1. Sedan", "1.2. Coupe", "1.3. SUV"]
Example 2
Input:
["# A", "## B", "# C", "## D"]
Output:
["1. A", "1.1. B", "2. C", "2.1. D"]
Example 3
Input:
["# 标题 ", "## \t子节 ", " # ignored", "# "]
Output:
["1. 标题 ", "1.1. \t子节 ", "2. "]
Example notes
The first example outputs ["1. Cars", "1.1. Sedan", "1.2. Coupe", "1.3. SUV"]. In the second example, section numbers reset after a new chapter. In the third example, the titles contain spaces, tabs and an empty title; after JSON decoding, the titles must be preserved character by character.
Editorial
Loading solution…