No.8051 cracked
note
This problem was created for yukicoder April fool contest 2019.
Update: 2023/07/09
Because the judge code did not support Ruby3.2, the judge code was fixed and a rejudge was performed.
After the rejudge, there appear to be some submissions that are judged TLE even though the special judge has judged them AC.
Problem Statement
The source code you submitted is given as input.
However, one byte with a character code between 32 and 126, inclusive, has been rewritten to a different byte with a character code between 32 and 126, inclusive.
Print to standard output the rewritten position (0-indexed, in bytes), the character before the rewrite, and the character after the rewrite.
If the source code exceeds 3000 bytes, or
if the source code contains no character that can be rewritten (for example, it consists only of newlines),
the string WA is given as input, and then the verdict will be WrongAnswer.
The characters with character codes from 33 to 126, inclusive, are listed below. Character code 32 is the half-width space.
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Also, write your program in C or C++14.
Any other language (Ruby, Python, etc.) will result in WrongAnswer.
When the following compilations are run on the submitted program, at least one of them must return exit code 0.
If both return exit code 0, the submission is interpreted as C code.
gcc7 -x c -std=c11 _filename_ g++ -x c++ _filename_
Added at 23:58: -std=gnu++14 has been removed from the C++ compile options.
Input
The source code you submitted is given, with one byte with a character code between 32 and 126, inclusive, rewritten to a different byte with a character code between 32 and 126, inclusive.
Output
On the first line, print the rewritten position (0-indexed, in bytes).
On the second line, print the character before the rewrite, enclosed in ".
On the third line, print the character after the rewrite, enclosed in ".
The trailing newline may be present or absent.
Hint
Since this is implemented as a reactive problem, there may be WA or TLE verdicts that do not occur in ordinary problems but do occur in reactive ones.
For example, EOF apparently does not arrive, so writing while(getchar() != -1); in C results in TLE.
Even if the exit code of the submitted program is nonzero, the verdict will not necessarily be RE.
Sample
Sample 1
main(){
printf("10\n\"p\"\n\"m\"");
}
Suppose the judge rewrites it as follows. This rewritten code is given from standard input.
main(){
mrintf("10\n\"p\"\n\"m\"");
}
p was rewritten to m.Also, from
m,a,i,n,(,),{,改行,半角SP,半角SP,p,..., we can see that byte 10 (0-indexed) has been rewritten.Therefore, you must print the following.
10 "p" "m"
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。