#P8413. 「SvR-1」Five of Pentacles
「SvR-1」Five of Pentacles
Background
UPD on 2023.2.5 by the problem setter: The original forced-online method has issues, which allows some solutions that rely on the forced-online method to pass, and that is not the correct solution but I do not want to change it.
Problem Description
Please read the Constraints and time limit carefully.
There is a number line of length . At the start of time , Little Z is at position , and at this moment, every position on the number line has an obstacle.
At each moment, if Little Z is at position , Little Z can choose a , then move to position , and will cross over every obstacle in .
Of course, everything changes. There will be changes in total. The -th change is as follows:
- During time , the obstacle at position will disappear.
- Note that this change only takes effect during time .
It is guaranteed that the changes happen in reverse chronological order, that is, is non-increasing.
Now, for each , you need to output, under the condition that the first changes happen, and with the requirement that at the end of time Little Z is exactly at position , the minimum number of obstacles crossed by Little Z.
Input Format
This problem is forced-online. Please pay attention to the online format.
The first line contains three integers .
Then follow lines. On line there are two numbers . Here is used to generate , namely: $x_i = \min(x_{i - 1} + p \oplus (lastans \bmod 15) + 1, m)$, where denotes the answer of the previous change.
In particular, before the first change, , , and when , treat as (note that this will not actually change the value of ).
Output Format
Output lines, each containing one integer, representing the required value.
2 3 2
2 0
2 3
3
2
Hint
Sample Explanation
After decrypting the sample:
2 3 2
2 1
2 2
- After the first change: In the first second, Little Z chooses and crosses one obstacle. In the second second, Little Z chooses and would originally cross obstacles, but in the second second, the first position has no obstacle, so only obstacles are crossed. In total, obstacles.
- After the second change: In the first second, Little Z chooses and crosses one obstacle. In the second second, only the third position has an obstacle, so choose , and only one obstacle is crossed. In total, obstacles.
Data Scale and Notes
This problem automatically enables bundled testdata and O2 optimization.
$$\newcommand{\arraystretch}{1.5} \begin{array}{c|c|c}\hline\hline \textbf{Subtask} & \bm{n,m,k\le} & \textbf{Score} \\\hline \textsf{1} & 100 & 15 \\\hline \textsf{2} & 2\times10^3 & 20 \\\hline \textsf{3} & 5\times10^4 & 20 \\\hline \textsf{4} & 10^6 & 20 \\\hline \textsf{5} & \text{No special constraints} & 25 \\\hline\hline \end{array}$$For of the data (after decryption), , , , is non-increasing; if are equal, sort by in increasing order; and for all , and are different.
This problem provides an input optimization method.
Using read(x); to read any integer x is equivalent to scanf("%d", &x);, where %d can be automatically recognized as the corresponding type.
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
template <typename T>
inline void read(T& r) {
r=0;bool w=0; char ch=getchar();
while(ch<'0'||ch>'9') w=ch=='-'?1:0,ch=getchar();
while(ch>='0'&&ch<='9') r=r*10+(ch^48), ch=getchar();
r=w?-r:r;
}
Translated by ChatGPT 5