Description
Solution
这题正解应该是Tarjan+拓扑排序。
然而我是来练std::bitset
优化Floyed的。
其实很好理解的,就是下面这段代码:
Code
//Floyed
For(j, 1, n) For(i, 1, n)
if (w[i][j]) w[i] |= w[j];
//Get the answer
int Ans = 0;
For(i, 1, n) Ans += w[i].count();
printf("%d\n", Ans);
//劝君莫惜花前醉,今年花谢,明年花谢,白了人头。
// -- 赵秉文《青杏儿·风雨替花愁》