JuQueen
Time limit3sMemory limit512 MB
Apply point and range frequency steps to cores clamped between 0 and N and report applied steps or queried states.
- Level
Medium6 of 10
- Topics
- Segment tree
- Solved
- No attempts yet
Problem
JuQueen is the highest performing supercomputer in Germany. It has 458,752 cores and sits at rank 8 on the top500 list. Its power draw goes up to 2,301 kW, so the operators want to cut it by underclocking the cores that are idle.
The cluster scheduler that spreads jobs over the nodes and cores issues these three speedstepping commands.
change X Schanges the frequency of core X by S steps.groupchange A B Schanges the frequency of every core in the range [A, B] by S steps.state Xreports the current step of core X.
To stay useful on larger machines, your program has to handle up to 4,587,520 cores. Every core starts at step 0.
Input
The input holds a single test case. The first line has three integers C, N, and O. C is the number of cores to manage (), N is the number of frequency steps one core can take (), so the step of each core is between 0 and N, and O is the number of commands in the test program (). Each of the next O lines holds one command as described above.
X, A and B are 0-based core ids with and . S is an integer that may be negative, with .
Both change and groupchange move the affected cores one step at a time and stop the moment one of them reaches the lowest step 0 or the highest step N. groupchange moves every core of the range together, so once one core in the range hits a bound the other cores stop where they are.
Output
Print one line for every command in the input. For change and groupchange print the number of steps actually applied, including its sign. Print 0 when no step could be applied. For state print the current step of that core.