QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#9269. C 和 Pascal 字符串

Statistics

在本题中,我们将处理字节序列。每个字节由两个十六进制数字(每位四比特,共八比特)给出,并被视为 $0$ 到 $\text{ff}_{16} = 255_{10}$(含)之间的无符号整数。十六进制数字通常表示为 0123456789abcdef

我们将 C ASCII 字符串定义为:以零个或多个范围在 $20_{16}$ 到 $7\text{f}_{16}$(含)之间的字节开头,后跟一个零字节的字节序列。零字节之后可以有任意字节,这些字节被称为“垃圾”字节。

我们将 Pascal ASCII 字符串定义为:以一个定义字符串长度的字节 $l$ 开头,后跟 $l$ 个范围在 $20_{16}$ 到 $7\text{f}_{16}$(含)之间的字节的字节序列。在这 $l$ 个字节之后可以有任意字节,它们也被称为“垃圾”字节。特别地,Pascal 字符串的长度限制在 $0$ 到 $\text{ff}_{16} = 255_{10}$ 的范围内。

给定一个以十六进制形式给出的整数序列 $b_i$ 作为内存转储。每个整数都在 $0$ 到 $\text{ff}_{16}$(含)的范围内。你的任务是确定以下四种情况中的哪一种成立:

  • 该转储既定义了一个有效的 C ASCII 字符串,也定义了一个有效的 Pascal ASCII 字符串;
  • 该转储定义了一个有效的 C ASCII 字符串,但不是有效的 Pascal ASCII 字符串;
  • 该转储定义了一个有效的 Pascal ASCII 字符串,但不是有效的 C ASCII 字符串;
  • 该转储既不是有效的 C ASCII 字符串,也不是有效的 Pascal ASCII 字符串。

注意,在所有情况下,都允许存在垃圾字节。

输入格式

输入包含一个不超过 $1000$ 个以空格分隔的十六进制整数序列;每个整数恰好由两个字符组成,每个字符都是 0123456789abcdef 中的一个。特别地,允许前导零。

输出格式

如果该转储既可以被解释为 C ASCII 字符串,也可以被解释为 Pascal ASCII 字符串,请打印单词 “Both”。

如果该转储可以被解释为 C ASCII 字符串,但不能被解释为 Pascal ASCII 字符串,请打印单词 “C”。

如果该转储可以被解释为 Pascal ASCII 字符串,但不能被解释为 C ASCII 字符串,请打印单词 “Pascal”。

如果该转储既不能被解释为 C ASCII 字符串,也不能被解释为 Pascal ASCII 字符串,请打印 “None”。

样例

输入格式 1

4d 4f 53 43 4f 57 00 5a

输出格式 1

C

输入格式 2

04 49 43 50 43 00

输出格式 2

Pascal

输入格式 3

05 4e 4f 4e 45 81

输出格式 3

None

输入格式 4

00 f4

输出格式 4

Both

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.