#include #include #include #include #include #define maxn 210 using namespace std; struct node{ int id,A,B; node(){} node(int x,int y,int z){ id=x,A=y,B=z; } }; vector e[maxn]; vector vec; int bel[maxn],A[maxn],B[maxn],dp[maxn][2],vis[maxn];; bool cmp(const node &x,const node &y){ return x.B>y.B; } void init(int n){ for(int i=1;i<=n;i++) e[i].clear(); } void dfs1(int now){ if(dp[now][0]!=-1) return; if(bel[now]==-1){ dp[now][0]=A[now]; dp[now][1]=B[now]; return; } for(int i=0;idp[now][0]){ dp[now][0]=dp[v][0]; dp[now][1]=dp[v][1]; } } else{ if(dp[v][1]>dp[now][1]){ dp[now][0]=dp[v][0]; dp[now][1]=dp[v][1]; } } } } int dfs2(int now,int limit){ if(vis[now]!=-1) return vis[now]; if(bel[now]==-1){ if(A[now]>limit) return vis[now]=0; return vis[now]=1; } for(int i=0;i