#P7603. [THUPC 2021] 鬼街
[THUPC 2021] 鬼街
Description
That street is known as the “Ghost Street”. Ten years ago, it was one of the busiest areas in City A, but now no living person lives there.
Along the street, there are houses scattered here and there. Each house has a unique number between and , painted in hellish black paint on broken tiles and crumbling bricks, faintly visible in the yellow dust.
It is said that the ghosts on this street are different from ghosts elsewhere. They like studying number theory and choose where to live based on properties of numbers, which is why they assigned a number to every house.
The newly appointed mayor of City A does not believe in such supernatural rumors. To find out the truth, he decides to install paranormal event monitors on this street.
There are events happening in order, as follows.
- Paranormal event: In the houses whose numbers are all prime factors of , each such house experiences haunting occurrences. For mysterious reasons, may be .
- Monitoring event: A monitor is installed. It monitors the houses whose numbers are all prime factors of . When the accumulated total number of haunting occurrences reaches the threshold , this monitor will trigger an alarm (if , then no matter which houses are being monitored, the next paranormal event will immediately trigger this monitor’s alarm). Haunting counts from different houses are tracked separately, and different monitors do not affect each other. All monitors are numbered consecutively starting from .
Please report all alarms to the mayor, that is, after each paranormal event, output which monitors are triggered.
Input Format
The first line contains two positive integers and , with .
The next lines each contain three non-negative integers , , and . Here . If is , it is a paranormal event; if is , it is a monitoring event. It is guaranteed that and . For mysterious reasons, you cannot directly obtain the real . Let be the number of monitors triggered by the previous paranormal event (if no paranormal event has happened yet, then ). The real is . The meanings of and in each event are as described above.
Output Format
For each paranormal event, output one line in order. The line starts with a non-negative integer , representing the number of alarms triggered by this paranormal event, followed by integers in increasing order, representing the indices of the monitors that are triggered.
20 9
1 10 2
0 5 0
0 6 1
0 7 1
0 15 1
1 12 3
0 8 0
1 5 0
0 8 2
0
0
0
1 1
0
2 2 3
Hint
【Sample Explanation】
In this sample, the following events happen in order:
- Monitor is installed. It monitors houses numbered and , with an alarm threshold of .
- A paranormal event happens. House seems to be haunted, but the number of occurrences is , so no alarms are triggered.
- A paranormal event happens. Houses and each have haunting occurrence. The accumulated count on monitor reaches , but it has not triggered an alarm yet.
- A paranormal event happens. House has haunting occurrence, and no alarms are triggered.
- A paranormal event happens. Houses and each have haunting occurrence. The accumulated count on monitor reaches the threshold , so it triggers an alarm.
- Monitor is installed. It monitors houses numbered and , with an alarm threshold of .
- A paranormal event happens. House has haunting occurrence. The accumulated count on monitor reaches , but it has not triggered an alarm yet.
- Monitor is installed, but its threshold is , so the next paranormal event will definitely trigger its alarm.
- A paranormal event happens. House has haunting occurrences. The accumulated count on monitor reaches , exceeding its alarm threshold , so it triggers an alarm. At the same time, monitor is also triggered.
【Source】
From the 2021 Tsinghua University Student Programming Contest and Collegiate Invitational (THUPC2021).
Resources such as editorials can be found at https://github.com/yylidiw/thupc_0/tree/master.
Translated by ChatGPT 5
京公网安备 11011102002149号