#P5466. [PKUSC2018] 神仙的游戏
[PKUSC2018] 神仙的游戏
Description
Little D and Little H are two immortals. They often play games that only immortals would play, such as “mentally checking whether a 4-digit number is a perfect square”.
Today they found a new game: first, for a string , a prefix of length is called a border if and only if . Given a string consisting of , replace each question mark in with or . For each , mentally determine whether there exists a way to replace the question marks such that the prefix of of length becomes a border, and record this result as . If the prefix of of length can become a border, then ; otherwise .
Since Little D and Little H are immortals, the length of they compute is very large, so comparing the results one by one would take a long time. To make comparison easier, they define a checksum: $(f(1)\times 1^2)~\operatorname{xor}~(f(2)\times 2^2)~\operatorname{xor}~(f(3)\times 3^2)~\operatorname{xor}~\dots~\operatorname{xor}~(f(n)\times n^2)$ to verify whether their answers are the same. denotes bitwise XOR. Unfortunately, in one game, the checksums they computed mentally were not the same. They want you to help them compute the correct checksum. Of course, they do not force you to do it mentally; you may solve it by programming.
Input Format
A string , guaranteed that each character is , , or .
Output Format
Output the checksum of the string, i.e. $(f(1)\times 1^2)~\operatorname{xor}~(f(2)\times 2^2)~\operatorname{xor}~(f(3)\times 3^2)~\operatorname{xor}~\dots~\operatorname{xor}~(f(n)\times n^2)$.
1?0?
17
Hint
Sample Explanation
Fill the question marks as 1001. Then this string has a border of length 1, so .
Fill the question marks as 1101. Then this string has a border of length 4, so .
For and , you can enumerate what characters are filled in to prove that their values are 0.
So the answer is .
Constraints
| Subtask ID | Additional Notes | Score | |
|---|---|---|---|
| 1 | None | 8 | |
| 2 | The input string has no question marks | 10 | |
| 3 | The testdata is random | 22 | |
| 4 | The number of question marks is at least | 27 | |
| 5 | None | 33 |
Translated by ChatGPT 5
京公网安备 11011102002149号