萌新求教

学术版

tarjan缩点后,直接拓扑排序 + dp
by Nuisdete @ 2020-08-11 18:56:50


你是求思想的?
by wd_dw @ 2020-08-11 18:56:53


这……我还没学过tarjan QAQ
by X_Chara @ 2020-08-11 19:05:35


@[louis_11](/user/202791)
by X_Chara @ 2020-08-11 19:07:18


@[代号_柒](/user/246188) 那数据多大?
by Nuisdete @ 2020-08-11 21:01:18


```cpp #include <bits/stdc++.h> using namespace std; const int MAXN = 2005; int n, ans; char a[MAXN]; bitset<MAXN> G[MAXN]; int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%s", a + 1); for(int j = 1; j <= n; j++) G[i][j] = a[j] == '1'; G[i][i] = 1; } for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) if (G[j][i]) G[j] |= G[i]; for(int i = 1; i <= n; i++) ans += G[i].count(); printf("%d", ans); return 0; } ```
by X_Chara @ 2020-08-13 14:44:59


做出来了 @[louis_11](/user/202791)
by X_Chara @ 2020-08-13 14:45:10


|