#P5332. [JSOI2019] 精准预测
[JSOI2019] 精准预测
Description
Currently, there are residents in the Mars town (numbered ). A machine learning algorithm predicts the life-or-death status of these residents over the next moments (numbered ). Each prediction is one of the following two types:
-
Brothers in Misfortune : At moment , if is dead, then at moment , is dead. (Note that if is alive at moment , this prediction is also considered correct.)
-
Death God Arrives : At moment , if is alive, then at moment , is dead. (Note that if is dead at moment , this prediction is also considered correct.)
Note that this problem is predicting the life-or-death status at a specific moment. If someone is alive at moment and dead at moment , you may assume that some event happened during the time interval from to that caused their death.
Although JYY is very confident in the model obtained from big data statistics, the Martians are shocked by these predictions and feel it is hard to accept such a setting. They even think computer science is a scary cult that has broken their peaceful life. To calm the Martians down, JYY plans to derive some facts from these prediction results that are easier for the Martians to accept.
Specifically, JYY first assumes that all predictions about the Martians' life and death are correct. Based on this, JYY wants to compute, for each resident , how many Martians might be able to live together with him until moment . In other words, for each Martian , JYY wants to compute
$$\sum_{1 \leq i \leq n,i \neq k} \operatorname{Live}(k,i)$$where means that Martians and may possibly both be alive at moment ; otherwise, .
Note that Martians cannot be resurrected. A Martian may already be dead at moment , and there may also be deaths not covered by any prediction (a Martian can die at any time, but at any moment, a Martian's observed state is either alive or dead). Finally, note that is computed independently for each pair of Martians, so and does not imply .
Input Format
The first line contains three integers . The next lines each describe a prophecy. The first integer of each prophecy indicates its type:
-
: then read ;
-
: then read .
Output Format
Output numbers as the answers, separated by spaces.
3 3 2
0 2 1 3
1 1 2 3
2 1 1
Hint

Translated by ChatGPT 5
京公网安备 11011102002149号