思路:
直接一个tarjan然后跑一遍dp+拓扑就A了,板子
c o d e code code
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int n, m, tot, cnt, tmp, tot1;
int stack[10010], top, ru[10010];
int a[10010], head[10010], head1[10010];
int dfn[10010], low[10010];
int d[10010], c[10010];
bool v[10010];
struct node
{
int from, to, next;
}b[100100], e[100100];
int ans[100010];
queue<int> q;
void add(int x,