QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100 Difficulty: [show]

#18232. APLSPC

Statistics

Welcome to SFLSPC!

Background

At the Antarctica Penguin Language School (APLS), penguins train every year on how to compress code and optimize for performance.

A penguin named "oo" is a spy sent by the Arctic Ocean Polar Bear Language School! It has infiltrated this competition, attempting to turn APLS into a colony for polar bears!

There is a hardworking and brave penguin who not only thwarted the evil polar penguin's subversion plan but also created all the data for APLSPC. Say it: Thank you, penguin.

There is a great penguin, it is very great, and it is the Emperor of the Antarctica Penguin Language School.

There is a "dudu" penguin, it is very "dudu". It sent you the "dudu-dudu" study materials and asked you to learn them.

There is a "tang-tang" penguin. Its $O(n\log n)$ code couldn't pass the $n\le 5\times 10^5$ data range within 2s, so it got very angry and decided to take revenge on society, thus creating this problem.

You need to write a piece of code that, for the required languages, satisfies:

  1. Under the compilation instructions for that language, it can run normally and output its own source code;
  2. It does not contain any keywords of that language under the definition of whole-word matching (if you do not know what whole-word matching is, please refer to the Implementation Details section).

These two requirements must be satisfied for both C++ and Python. That is, this code must be valid C++ and Python code simultaneously, and satisfy the above requirements.

Given this, your code should also be as short as possible.

If your code satisfies all conditions and its length does not exceed 250B, you will receive $100$ points. If your code does not satisfy some conditions, you can still receive partial points; see the Scoring section for details.

Note: We will use methods to ensure that your code does not have access to the source file in the runtime directory; you cannot and should not attempt to complete the task by calling the source file.

If you are not familiar with the syntax, you can visit python.org or cppreference.com for relevant information.

Implementation Details

Your code must not contain non-ASCII characters, otherwise the result is undefined.

First, all line breaks in your code will be forcibly converted to CRLF (\r\n), so one line break occupies two bytes.

Next, the judge will run your code using the following commands:

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

Then, the judge will use the following command to determine if your code outputs itself:

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

This command treats the CRLF at the end of a line as LF, meaning you do not need to worry about special line breaks when outputting your code.

In addition, this command performs a strictly exact comparison, meaning that whitespace characters such as trailing spaces must also be exactly identical.

Finally, the judge will check if your code contains any keywords from the keyword list using whole-word matching. The definition of whole-word matching is that the characters immediately preceding and following the matched position are not digits, letters, or underscores. For example, int can match (int), but cannot match print. The keyword lists are attached at the end of the problem.

It is particularly important to note that the specified time limit is meaningless; the actual limit is 1000ms. If your code runs for more than 1000ms, it will be forcibly terminated, but the running time and memory usage will not be reflected in the evaluation results.

Scoring

Define your preliminary score $s_0$:

  • Regardless of whether the code contains keywords, if your code is valid C++ code and outputs itself when run as C++, but is not valid Python code, $s_0=2$.

  • Regardless of whether the code contains keywords, if your code is valid C++ and Python code, and outputs itself when run as C++, but not when run as Python, $s_0=10$.

  • Regardless of whether the code contains keywords, if your code is valid C++ and Python code and outputs itself in both languages, let $x$ be the length of your code:

$$ 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} $$

  • In all other cases, $s_0=0$.

$f(x)$ is a continuous function. Note that $s_0$ may be greater than $100$.

Finally, if your code does not contain any keywords, your final score is $\lfloor\min(100,s_0)\rfloor$, otherwise it is $\lfloor\min(70,0.7s_0)\rfloor$.

Keyword List

The following is the C++ keyword list:

{
    "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"
}

The following is the Python keyword list:

{
    "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"
}

Note

  • The C++ main function does not need to define a return type. That is, the following is a piece of valid C++ code:
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.