DP:求出3点构成链的方案数 ,然后总方案数减去它
Y
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1738 Accepted Submission(s): 493
Problem Description
Sample Input
4 1 2 1 3 1 4
Sample Output
1
Hint
1. The only set is {2,3,4}.
2. Please use #pragma comment(linker, "/STACK:16777216")
Source 2013 Multi-University Training Contest 10
#include#include #include #include #include #pragma comment(linker, "/STACK:16777216") using namespace std; typedef long long int LL; const int maxn=100100; vector g[maxn]; int n; LL ans,doubi[maxn],son[maxn]; void dfs(int u,int fa) { LL ndoubi=0,nson=0; son[u]=1; for(int i=0,sz=g[u].size();i