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.