QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#2399. MrCodeFormatGrader

Statistics

讲师 Bob 正在构建一个自动源代码格式评分网站,网站名称为 “MrCodeFormatGrader”。当你运行 Bob 的程序并提交源代码时,程序会输出 $C$(源代码的总行数)、$N$(存在格式错误的源代码行数),以及一个格式错误的行号列表。行号按升序排列,并以空格分隔。

例如,对于一个 100 行的程序,如果第 2, 3, 5, 10, 11, 12, 25, 26, 88, 89 行存在 10 个错误,原始程序可能会输出:

100 10
2 3 5 10 11 12 25 26 88 89

然而,使用该程序的用户反映输出的可读性不佳。你的任务是读取上述输出,并展示两个列表:一个是压缩后的错误行列表,另一个是压缩后的正确行列表。

输入格式

输入包含两行。第一行包含两个整数:$C$(被检查程序中的源代码总行数,其中 $2 \le C \le 100\,000$)和 $N$(包含格式错误的源代码行数,其中 $1 \le N \le \min(C, 1\,000)$)。第二行输入包含 $N$ 个值,标识存在格式错误的源代码行号。这些值是小于或等于 $C$ 的正整数,并按严格递增的顺序排列。

输出格式

输出包含两行。第一行应以字符串 “Errors:” 开头,后跟一个空格,再后跟错误行列表。第二行应以字符串 “Correct:” 开头,后跟一个空格,再后跟正确行列表。对于这两个列表,连续的行号集合应通过列出起始行和结束行并用连字符(‘-’)分隔来表示。在包含两个或更多项的列表中,各项应以逗号和空格分隔,但每个列表的最后一个值(或最后一组连续值)之前应使用 “and” 而不是逗号和空格。请参考样例输出。注意:每个程序至少会有一个错误行和至少一行正确行。

样例

样例输入 1

100 10
2 3 5 10 11 12 25 26 88 89

样例输出 1

Errors: 2-3, 5, 10-12, 25-26 and 88-89
Correct: 1, 4, 6-9, 13-24, 27-87 and 90-100

样例输入 2

40 18
1 3 4 6 7 8 9 12 13 14 20 25 26 27 28 30 38 40

样例输出 2

Errors: 1, 3-4, 6-9, 12-14, 20, 25-28, 30, 38 and 40
Correct: 2, 5, 10-11, 15-19, 21-24, 29, 31-37 and 39

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.