摘要:
这道题我最开始是想着用dfs的但一看数据量肯定会超时,看了视频才发现可以用spfa,虽然是无权图,但我们可以把边权看作一,我们只需要记录到1的最短距离,如果vc[u][i].dis+w[u]==w[v]那就cnt[v]=(cnt[v]+cnt[u])%100003;如果遇到vc[u][i].dis+ 阅读全文
posted @ 2025-02-19 15:42
郭轩均
阅读(27)
评论(0)
推荐(0)
摘要:
由于题目没有说是连通图,所以最开始时要把所有点加入队列 #include<iostream> #include<queue> #include<vector> using namespace std; struct node { int id; int dis; }; const int N=5*1 阅读全文
posted @ 2025-02-19 14:42
郭轩均
阅读(30)
评论(0)
推荐(0)
摘要:
这道题要用floyd算法,如果a可以战胜b,b可以战胜c,那么a可以战胜c,并且这道题的数据范围很小,首先遍历第i头奶牛可以战胜几头奶牛,然后再统计有几头奶牛可以战胜它,如果加起来等于n-1,说明它与其它所有的奶牛的关系都确定了, #include<iostream> using namespace 阅读全文
posted @ 2025-02-19 14:11
郭轩均
阅读(28)
评论(0)
推荐(0)

浙公网安备 33010602011771号