← 返回 optiver 的题目列表Overheat Prevention Controller
类型:online_judge
Problem: Overheat Prevention Controller
Implement an overheat prevention controller for a multi-core microprocessor. The controller simulates each CPU core's load, temperature, and power state purely in software.
The system has no physical sensors. Temperatures are computed from power load and cooling capacity.
You need to implement an OverheatPreventionController and support the following commands:
set t core_id load: at timestamp t, set the load of core_id to load Watts.
If the core is currently SHUTDOWN, this command restarts it.
After restart, its temperature is reset to 0, its state becomes ON, and its load becomes load.
If the core is already ON, only its load is updated.
tick t: advance the simulation to timestamp t, process all pending set events with timestamp <= t, and output the core IDs whose states have changed since the previous tick.
State changes only include ON -> SHUTDOWN and SHUTDOWN -> ON.
If a core changes state at least once between two tick calls, output it once.
Output core IDs in lexicographical order.
If no core changed state, output -.
Temperature Model
The system has:
N cores;
total passive cooling capacity P;
per-active-core active cooling capacity A;
overheat threshold LIMIT.
Initially:
all cores are ON;
all temperatures are 0;
all loads are 0;
current timestamp is 0.
For any time interval [cur, nxt]:
dt = nxt - cur
active_count = number of ON cores
If active_count > 0, passive cooling is evenly shared by all ON cores:
passive_share = P / active_count
For each ON core:
temperature += (load - A - passive_share) * dt
temperature = max(0, temperature)
A SHUTDOWN core keeps its temperature unchanged while shut down, and its load is considered 0.
After each simulation segment, if an ON core satisfies:
temperature >= LIMIT
it immediately becomes SHUTDOWN, and its load becomes 0.
Event Processing Rules
For a tick t:
Process all set events in increasing timestamp order.
For multiple set events with the same timestamp, process them in input order.
Before applying each set event, first advance the simulation to that event timestamp and check for overheating.
After all set events with timestamp <= t are processed, advance the simulation to t.
Input Format
N P A LIMIT Q
core_id_1 core_id_2 ... core_id_N
Then Q lines, each being one command:
set t core_id load
or
tick t
Output Format
For each tick command, print one line:
If at least one core changed state, print their IDs in lexicographical order separated by spaces;
Otherwise print -.
Constraints
1 <= N <= 2000
1 <= Q <= 5000
0 <= P, A, LIMIT, load <= 10^6
0 <= t <= 10^9
core_id contains only letters, digits, and underscores, and all IDs are unique
All set timestamps are not earlier than the current simulation time
All tick timestamps are not earlier than the current simulation time
Example
Input:
2 10 2 100 4
c0 c1
set 0 c0 20
tick 5
tick 10
tick 11
Output:
-
c0
-
Example
Input
2 10 2 100 4
c0 c1
set 0 c0 20
tick 5
tick 10
tick 11
Output
-
c0
-