$ Luogu $ $ P2024 $ $ [NOI2001] $ food chain

link

background

\ (The CCF \) \ (the NOI \) \ (2001 \) \ (Day1 \) \ (Tl \) , \ (Luogu \) \ (P1955 / Vijos1531 \)

The meaning of problems

Given three animals \ (A, B, C \ ) co \ (n-\) only (now uncertain species). Predetermined \ (A \) eat \ (B \) , \ (B \) eat \ (C \) , \ (C \) eat \ (A \) , gives \ (n-\) otherwise shaped as \ ( 1 XY (X, Y \ in [1, n]) \) or \ (the XY 2 (X-, the Y \ in [. 1, n-]) \) , before a description of \ (X-\) and \ (the Y \ ) is the same. After a description of \ (X-\) eat \ (the Y \) . Provision sentence is false case, there are three: the first is the number of animals given more than \ (the n-\) , and the second is the current phrase with the words appear as early as contradictory than it is currently the third as saying \ (X \) eat \ (the X-\) . Seeking the number of lies.

solution

The famous extension field disjoint-set (the kind of disjoint-set) played it!
Because the relationship only to eat and be eaten the same three types consider each animal \ (x (x \ in [ 1, n]) \) is split into a collection of Sa \ (x_self, x_enemy, x_eat \) , respectively, said their similar collections, a collection of predators and food collection.
No network, and more then a little later.

Guess you like

Origin www.cnblogs.com/Peter0701/p/11815459.html