#P2024. [NOI2001] 食物链
[NOI2001] 食物链
Description
In the animal kingdom, there are three kinds of animals , and their food chain forms an interesting cycle. eats , eats , and eats .
There are animals, numbered from to . Each animal is one of , but we do not know which.
Someone describes the food chain relationships among these animals using two kinds of statements:
- Type 1:
1 X Ymeans and are of the same kind. - Type 2:
2 X Ymeans eats .
This person makes statements, one after another. Some are true and some are false. A statement is false if and only if it satisfies at least one of the following:
- It contradicts some previous true statements.
- or is greater than .
- It claims that eats .
Your task is to output the total number of false statements.
Input Format
The first line contains two integers , indicating there are animals and statements.
Starting from the second line, each line contains one statement. The formats are as described in the problem statement and the samples.
Output Format
One line containing a single integer: the total number of false statements.
100 7
1 101 1
2 1 2
2 2 3
2 3 3
1 1 3
2 3 1
1 5 5
3
Hint
Constraints: For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号