Solving the problem Foodchain while practicing union-find sets
There are N animals with index 1, 2, ..., N. Every animal belongs to category A or B or C. Knowing that A eats B, B eats C, C eats A, this program should judge whether these K informations is correct, and print the count of wrong informations.
- x and y are in the same category.
- x eats y.
1<=N<=50000
0<=K<=10000
The first line has two Integer: N and K.
Then there are K lines of information, and every line has 3 Integers, representing for "the type of information" "x" "y".
100 7
1 101 1
2 1 2
2 2 3
2 3 3
1 1 3
2 3 1
1 5 5
3
Information 1, 4, 5 are wrong.