2022 Shanghai Collegiate Programming Contest - M. My University Is Better Than Yours 缩点+dp

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.
https://www.zizhengfang.com/applets/transitivity
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(1n5×105

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柯西可乐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值