QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100 الصعوبة: [عرض]

#18232. APLSPC

الإحصائيات

广告

欢迎大家参加 SFLSPC!

题目背景

在南极洲企鹅语学校(Antarctica Penguin Language School),企鹅们每年训练如何给代码压行和卡常。

有一只 oo 的企鹅是北冰洋北极熊语学校派来的间谍!它已经渗透进了这场比赛,企图把 APLS 变成北极熊的殖民地!

有一只勤劳又勇敢的企鹅,它不仅挫败了邪恶的北极企鹅的颠覆计划,还造了 APLSPC 的所有数据,快说:谢谢企鹅。

有一只伟大的企鹅,它非常伟大,是南极洲企鹅语学校的大帝。

有一只嘟嘟的企鹅,它很嘟嘟。它把嘟嘟嘟大学习发给了你要求你学习。

有一只糖糖的企鹅,它写的 $O(n\log n)$ 代码居然卡不进 $n\le 5\times 10^5$ 2s 的的数据范围,它很生气,决定报复社会,于是出了这道题。

题目描述

你需要编写一份代码,对于所要求的语言,满足:

  1. 在该语言的编译指令下,能正常运行并输出自身;
  2. 全字匹配意义下不包含任何该语言的关键字(如果你不知道什么是全字匹配,请参考评测细节一栏)。

这两个要求对于 C++ 和 Python 都必须满足。也就是说,这份代码要同时是合法的 C++ 和 Python 代码,并且满足以上要求。

在此前提下,你的代码还要尽可能短。

若你的代码满足所有条件并且长度不超过 250B,你将获得 $100$ 分。若你的代码有一些条件没有满足,也能得到一定的分数,详见评分方式。

注意,我们会采用手段使得你的代码在运行时目录下没有源码,你不能也不应该采用调用源码文件等方式完成任务。

如果你对语法不熟悉,你可以访问 python.orgcppreference.com 获取相关信息。

评测细节

你的代码不可以包含非 ASCII 字符,否则结果是未定义的。

首先,你的代码的所有换行符都会被强制换成 CRLF(\r\n),所以一个换行占据两个字节。

接下来,评测机会分别调用以下指令来运行你的代码:

/usr/bin/g++ code.cpp -std=c++2a -O2 -o code && ./code
python3 code.cpp

然后,评测机会使用以下指令来判断你的代码是否输出自身:

diff --strip-trailing-cr code.cpp out

这条指令会把行末的 CRLF 视为 LF,也就是说,你的代码在输出时无需关心特殊的换行符。

除此以外,该指令会进行完全严格的比较,也就是说行末空格等空白字符也必须完全一致

最后,评测机会从关键字列表里查找你的代码是否包含关键字,查找方式为全字匹配。全字匹配的定义是,匹配的位置前后一个字符均不为数字,字母或下划线。如 int 可以匹配 (int),但不能匹配 print。关键字列表附在题目最后。

需要特别注意的是,标定的时间限制无意义,实际限制为 1000ms。你的代码如果运行超过 1000ms 将被强制结束,但是运行时间和空间并不会反映在评测结果中。

评分方式

定义你的初步分数 $s_0$:

  • 无论代码是否包含关键字,如果你的代码是 C++ 的合法代码,并且在 C++ 运行下输出了自身,但不是 Python 的合法代码,$s_0=2$。

  • 无论代码是否包含关键字,如果你的代码同时是 C++ 和 Python 的合法代码,并且在 C++ 运行下输出了自身,但在 Python 下没有,$s_0=10$。

  • 无论代码是否包含关键字,如果你的代码同时是 C++ 和 Python 的合法代码且在两种语言下都输出了自身,令 $x$ 为你的代码长度,

$$ s_0=f(x)= \begin{cases} 20&(x\ge10^4)\\ 45-\frac{x}{400}&(2000\le x<10^4)\\ \frac{200}{3}-\frac{x}{75}&(500\le x<2000)\\ 135-\frac{3x}{20}&(300\le x<500)\\ 150-\frac{x}{5}&(x<300) \end{cases} $$

  • 其他情况下 $s_0=0$。

$f(x)$ 是连续函数。注意 $s_0$ 可能大于 $100$。

最后,若你的代码不包含关键字,则你的最终得分为 $\lfloor\min(100,s_0)\rfloor$,否则为 $\lfloor\min(70,0.7s_0)\rfloor$。

关键字列表

以下是 C++ 的关键字列表:

{
    "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break",
    "case", "catch", "char", "char8_t", "char16_t", "char32_t", "class", "compl", "concept",
    "const", "consteval", "constexpr", "constinit", "const_cast", "continue", "co_await",
    "co_return", "co_yield", "decltype", "default", "delete", "do", "double", "dynamic_cast",
    "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto",
    "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq",
    "nullptr", "operator", "or", "or_eq", "private", "protected", "public", "register",
    "reinterpret_cast", "requires", "return", "short", "signed", "sizeof", "static",
    "static_assert", "static_cast", "struct", "switch", "synchronized", "template", "this",
    "thread_local", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned",
    "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
}

以下是 Python 的关键字列表:

{
    "False", "None", "True", "and", "as", "assert", "async", "await", "break", "class",
    "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global",
    "if", "import", "in", "is", "lambda", "nonlocal", "not", "or", "pass", "raise", "return",
    "try", "while", "with", "yield", "match", "case"
}

提示

  • C++ 的 main 函数可以不定义返回类型。即,以下是一份合法的 C++ 代码:
    main(){}

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.