需要用拓扑排序解决dp的无后效性
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int head[maxn];
int dfn[maxn];
int low[maxn];
bool vis[maxn];
int colour[maxn];
int dv[maxn];
int indu[maxn];
int dist[maxn];
int tot;
int tot1;
int dex;
int cnt;
int n, m;
int ans;
struct node{
int to;
int next;
int from;
node() {}
node(int a, int b, int c) : to(a), next(b), from(c) {}
}edge[maxn], edge1[maxn];
void edgeadd(int a, int b){
edge[tot] = node(b, head[a], a);
head[a] = tot++;
}
void edgeadd1(int a, int b){
edge1[tot1] = node(b, head[a], a);
head[a] = tot1++;
}
void init(){
memset(head, -1, sizeof(head));
memset(vis, 0, sizeof(vis));