M. My University Is Better Than Yours
题目描述
People rank for things. Yes, ranking is nothing for most of the time, except when you are doing year-end report to your boss.
Under the promotion of the construction of world-class universities, a lot of universities are struggling to improve ranking in every way. Publishing papers, applying for funds, improving diversity… They are too hard and your result may not be fairly judged by institutions like US News and Times! However, some universities are more clever – they publish their own rankings, which makes the ranking indirectly better. For example, using Shanghai Ranking’s Academic Ranking of World Universities (ARWU) produced by Shanghai Jiao Tong University, Desprado2 can prove that his school is better than MIT.

Anyway, that is a joke unless you are finding jobs and need to brag about your school. But at the same time, Desprado2 comes out a problem: assume there are n n n universities in total, and he has collected m university rankings. For simplicity, all the universities are denoted by a number from 1 1 1 to n n n. Here, Desprado2 defines that university x x x is directly better than university y, if and only if there exists a university ranking such that university x x x ranks higher than university y y y. Furthermore, Desprado2 defines that university x x x is b e t t e r better better than university y y y, if and only if there exists a sequence {s1, s2, …, sk} (k≥2), such that:
s 1 = x , s k = y s_1=x, s_k=y s1=x,sk=y
∀i∈{1,2,…,k−1}, university si is directly better than university s i + 1 s_{i+1} si+1
For each university, Desprado2 want you to tell him it is better than how many of other universities.
输入描述
The first line contains two integers n n n and m ( 1 ≤ n ≤ 5 × 1 0 5 , 1 ≤ m ≤ 5 × 1 0 5 , 1 ≤ n × m ≤ 1 0 6 ) m (1≤n≤5×10^5, 1≤m≤5×10^5, 1≤n×m≤10^6) m(1≤n≤5×105

最低0.47元/天 解锁文章
786

被折叠的 条评论
为什么被折叠?



