answer. Computer science. society can be addressed by an associated, undirected chart of n vertices and m edges. The vertices address individuals, and an edge (i,j) addresses a companionship between individuals I and j. In the public eye, the I-th individual has a pay artificial intelligence. An individual I is desirous of
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
society can be addressed by an associated, undirected chart of n vertices and m edges. The vertices address individuals, and an edge (i,j) addresses a companionship between individuals I and j.
In the public eye, the I-th individual has a pay
The general public is called entrepreneur if for each pair of companions one is desirous of the other. For certain fellowships, you know which companion is jealous of the other. For the leftover fellowships, you don't have the foggiest idea about the bearing of jealousy.
The pay imbalance of society is characterized as max1≤i≤nai−min1≤i≤nai.
You just know the fellowships and not the livelihoods. In case it is outlandish for this general public to be industrialist with the given information, you should report about it. Any other way, you should find a task of salaries where the general public is industrialist, and the pay disparity is boosted.
Input
The principal line contains two integers n, m (1≤n≤200, n−1≤m≤2000) — the number of individuals and companionships, separately.
The accompanying m lines depict the kinships. Every fellowship is portrayed by three integers I, j, b (1≤i,j≤n,i≠j,0≤b≤1). This means that individuals I and j are companions. In the event that b=1, we necessitate that individual I is desirous of individual j. In the event that b=0, one companion ought to be desirous of the other one or the other way.
There is all things considered one companionship between each pair of individuals. It is ensured that on the off chance that we think about the fellowships as undirected edges, the diagram is associated.
Output
Print "YES" in case it is conceivable that the general public is industrialist, or "NO" in any case. You can print characters regardless (upper or lower).
If the appropriate response is "YES", you should print two extra lines. In the main line, print the most extreme conceivable pay disparity. On the following line you should print n integers a1,… ,an (0≤ai≤106), where artificial intelligence indicates the pay of the I-th individual.
We can demonstrate that if there exists an answer, there exists one where 0≤ai≤106 for all I.
On the off chance that there exist numerous arrangements, print any.
Step by step
Solved in 4 steps with 1 images