CF794D Labelling Cities
Description
Oleg the bank client lives in Bankopolia. There are $ n $ cities in Bankopolia and some pair of cities are connected directly by bi-directional roads. The cities are numbered from $ 1 $ to $ n $ . There are a total of $ m $ roads in Bankopolia, the $ i $ -th road connects cities $ u_{i} $ and $ v_{i} $ . It is guaranteed that from each city it is possible to travel to any other city using some of the roads.
Oleg wants to give a label to each city. Suppose the label of city $ i $ is equal to $ x_{i} $ . Then, it must hold that for all pairs of cities $ (u,v) $ the condition $ |x_{u}-x_{v}|
Input Format
The first line of input contains two space-separated integers $ n $ and $ m $ ( $ 2
Output Format
If the required labeling is not possible, output a single line containing the string "NO" (without quotes).
Otherwise, output the string "YES" (without quotes) on the first line. On the next line, output $ n $ space-separated integers, $ x_{1},x_{2},...,x_{n} $ . The condition $ 1
Explanation/Hint
For the first sample, $ x_{1}=2 $ , $ x_{2}=3 $ , $ x_{3}=x_{4}=1 $ is a valid labeling. Indeed, $ (3,4) $ , $ (1,2) $ , $ (1,3) $ , $ (1,4) $ are the only pairs of cities with difference of labels not greater than $ 1 $ , and these are precisely the roads of Bankopolia.
For the second sample, all pairs of cities have difference of labels not greater than $ 1 $ and all pairs of cities have a road connecting them.
For the last sample, it is impossible to construct a labeling satisfying the given constraints.