#P14600. [NWRRC 2025] Asynchronous Processor
[NWRRC 2025] Asynchronous Processor
题目描述
You are given a program consisting of instructions executed by a processor with a single integer register , initially equal to . Each instruction is one of two types:
- --- performs ;
- --- performs .
The instructions in the program are numbered from to . Each instruction initially has timestamp .
Some instructions are marked as . If instruction is asynchronous, its timestamp can be changed to any number greater than .
After all timestamp adjustments, all timestamps must be distinct. The processor then executes the instructions in order of increasing timestamp.
Determine the number of distinct final values of that can be obtained after all instructions have been executed, considering all possible choices of asynchronous instruction timestamps.
输入格式
The first line contains an integer , denoting the number of instructions in the program ().
The -th of the following lines describes instruction and contains three tokens. The first token is either or , denoting the type of the instruction. The second token is an integer , denoting the argument of the instruction (). Finally, the third token is either if the instruction is marked as asynchronous, or otherwise.
输出格式
Print the number of distinct final values can take after executing the program.
2
30
提示
In the first test, the program execution starts with instruction setting to . Then, instructions and are executed in one of the two orders:
- if is executed before , will be equal to ;
- if is executed before , will be equal to .
Thus, there are two possible values of at the end: and .
京公网安备 11011102002149号