QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#3311. 数字不仅仅是字符

Statistics

Manuel Majorana Minore 先生创建了许多文件名中包含数字的文件。他希望列出这些文件,但常用的文件列表命令所给出的排序方式与他偏好的不同,因为该命令将文件名中的数字序列视为 ASCII 码序列,而不是数字。例如,文件 file10file20file3 会按此顺序排列。

请编写一个程序,通过将数字序列解释为数值来决定文件名的排序。

每个文件名由大写字母(从 ‘A’ 到 ‘Z’)、小写字母(从 ‘a’ 到 ‘z’)和数字(从 ‘0’ 到 ‘9’)组成。

文件名被视为一系列项,每一项要么是一个字母,要么是一个数字。每个单独的大写或小写字母构成一个字母项。每个连续的数字序列构成一个数字项。

两项的排序规则如下: 数字项排在字母项之前。 两个字母项按其 ASCII 码排序。 * 两个数字项按其作为十进制数解释时的数值排序。

两个文件名从头开始逐项进行比较,第一个不同的对应项决定了文件名的顺序。如果其中一个文件名(设为 $A$)比另一个(设为 $B$)包含更多的项,且 $B$ 的所有项都与 $A$ 的对应项相同,则 $B$ 应排在前面。

例如,样例输入 1 中的三个文件名 file10file20file3 都以相同的四个字母项序列 file 开头,后面分别跟着数字项 10203。比较这些数字项的数值,它们的顺序为 file3 < file10 < file20

输入格式

输入包含单个测试用例,格式如下:

$n$ $s_0$ $s_1$ $\vdots$ $s_n$

第一行的整数 $n$ 给出了需要与下一行给出的文件名 ($s_0$) 进行比较的文件名数量($s_1$ 到 $s_n$)。其中,$1 \le n \le 1000$。

接下来的 $n+1$ 行是文件名 $s_0$ 到 $s_n$,每行一个。它们至少包含一个字符,且不超过九个字符。每个字符要么是大写字母、小写字母,要么是数字。

文件名中的数字序列从不以数字零 (0) 开头。

输出格式

对于每个文件名 $s_1$ 到 $s_n$,输出一行,用一个字符表示它是否应排在 $s_0$ 之前。如果它应排在 $s_0$ 之前,则该字符应为 “-”,否则为 “+”(包括两个文件名相同的情况)。

样例

样例输入 1

2
file10
file20
file3

样例输出 1

+
-

样例输入 2

11
X52Y
X
X5
X52
X52Y
X52Y6
32
ABC
XYZ
x51y
X8Y
X222

样例输出 2

-
-
-
+
+
-
-
+
+
-
+

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.